Passed
Pull Request — master (#191)
by
unknown
04:15
created
vendor/composer/installers/src/bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
     }
7 7
 }
8 8
 if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
9
-    die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
10
-        'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
11
-        'php composer.phar install'.PHP_EOL);
9
+    die('You must set up the project dependencies, run the following commands:' . PHP_EOL .
10
+        'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
11
+        'php composer.phar install' . PHP_EOL);
12 12
 }
13 13
 return $loader;
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 4 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				<?php
197 197
 				if(! empty( $insert_shortcode_function )){
198 198
 					echo $insert_shortcode_function;
199
-				}else{
199
+				} else{
200 200
 
201 201
 				/**
202 202
 				 * Function for super duper insert shortcode.
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 								// If the user sets block-output array then build it
1069 1069
 								if ( ! empty( $this->options['block-output'] ) ) {
1070 1070
 								$this->block_element( $this->options['block-output'] );
1071
-							}else{
1071
+							} else{
1072 1072
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1073 1073
 								?>
1074 1074
 								el('div', {
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		 * @param string $id
269 269
 		 * @param string $search_for_id
270 270
 		 *
271
-		 * @return mixed
271
+		 * @return string
272 272
 		 */
273 273
 		public static function shortcode_button( $id = '', $search_for_id = '' ) {
274 274
 			ob_start();
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		 * Makes SD work with the siteOrigin page builder.
299 299
 		 *
300 300
 		 * @since 1.0.6
301
-		 * @return mixed
301
+		 * @return string
302 302
 		 */
303 303
 		public static function siteorigin_js() {
304 304
 			ob_start();
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 		/**
858 858
 		 * Gets some CSS for the widgets screen.
859 859
 		 *
860
-		 * @return mixed
860
+		 * @return string
861 861
 		 */
862 862
 		public function widget_css() {
863 863
 			ob_start();
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 		/**
898 898
 		 * Gets some JS for the widgets screen.
899 899
 		 *
900
-		 * @return mixed
900
+		 * @return string
901 901
 		 */
902 902
 		public function widget_js() {
903 903
 			ob_start();
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 		 *
1348 1348
 		 * @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.
1349 1349
 		 * @since 1.0.9 Save numbers as numbers and not strings.
1350
-		 * @return mixed
1350
+		 * @return string
1351 1351
 		 */
1352 1352
 		public function block() {
1353 1353
 			ob_start();
Please login to merge, or discard this patch.
Indentation   +1360 added lines, -1360 removed lines patch added patch discarded remove patch
@@ -1,141 +1,141 @@  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.3 is_block_content_call() method added.
16
-	 * @since 1.0.3 Placeholder text will be shown for widget that return no block content.
17
-	 * @since 1.0.4 is_elementor_widget_output() method added.
18
-	 * @since 1.0.4 is_elementor_preview() method added.
19
-	 * @since 1.0.5 Block checkbox options are set as true by default even when set as false - FIXED
20
-	 * @since 1.0.6 Some refactoring for page builders - CHANGED
21
-	 * @since 1.0.7 Some refactoring for page builders - CHANGED
22
-	 * @since 1.0.8 Some refactoring for page builders ( cornerstone builder now supported ) - CHANGED
23
-	 * @since 1.0.9 Numbers saving as strings and not numbers which can cause block render issues on refresh - FIXED
24
-	 * @since 1.0.10 Some refactoring for page builders ( Avia builder for Enfold theme now supported ) - CHANGED
25
-	 * @ver 1.0.10
26
-	 */
27
-	class WP_Super_Duper extends WP_Widget {
28
-
29
-		public $version = "1.0.10";
30
-		public $block_code;
31
-		public $options;
32
-		public $base_id;
33
-		public $arguments = array();
34
-		public $instance = array();
35
-		private $class_name;
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
-				// register block
68
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
69
-			}
70
-
71
-			// add the CSS and JS we need ONCE
72
-			global $sd_widget_scripts;
73
-
74
-			if ( ! $sd_widget_scripts ) {
75
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
76
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
77
-				wp_add_inline_style( 'widgets', $this->widget_css() );
78
-
79
-				$sd_widget_scripts = true;
80
-
81
-				// add shortcode insert button once
82
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
83
-				if ( $this->is_preview() ) {
84
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
85
-					// this makes the insert button work for elementor
86
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
87
-						$this,
88
-						'shortcode_insert_button_script'
89
-					) ); // for elementor
90
-				}
91
-				// this makes the insert button work for cornerstone
92
-				add_action( 'cornerstone_load_builder', array(
93
-					$this,
94
-					'shortcode_insert_button_script'
95
-				) ); // for cornerstone builder (this is the preview)
96
-
97
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
98
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
99
-
100
-				// add generator text to admin head
101
-				add_action( 'admin_head', array( $this, 'generator' ) );
102
-			}
103
-
104
-			do_action( 'wp_super_duper_widget_init', $options, $this );
105
-		}
106
-
107
-		/**
108
-		 * A function to ge the shortcode builder picker html.
109
-		 *
110
-		 * @param string $editor_id
111
-		 *
112
-		 * @return string
113
-		 */
114
-		public static function get_picker( $editor_id = '' ) {
115
-
116
-			ob_start();
117
-			if ( isset( $_POST['editor_id'] ) ) {
118
-				$editor_id = esc_attr( $_POST['editor_id'] );
119
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
120
-				$editor_id = 'main_content_content_vb_tiny_mce';
121
-			}
122
-
123
-			global $sd_widgets;
124
-			?>
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.3 is_block_content_call() method added.
16
+     * @since 1.0.3 Placeholder text will be shown for widget that return no block content.
17
+     * @since 1.0.4 is_elementor_widget_output() method added.
18
+     * @since 1.0.4 is_elementor_preview() method added.
19
+     * @since 1.0.5 Block checkbox options are set as true by default even when set as false - FIXED
20
+     * @since 1.0.6 Some refactoring for page builders - CHANGED
21
+     * @since 1.0.7 Some refactoring for page builders - CHANGED
22
+     * @since 1.0.8 Some refactoring for page builders ( cornerstone builder now supported ) - CHANGED
23
+     * @since 1.0.9 Numbers saving as strings and not numbers which can cause block render issues on refresh - FIXED
24
+     * @since 1.0.10 Some refactoring for page builders ( Avia builder for Enfold theme now supported ) - CHANGED
25
+     * @ver 1.0.10
26
+     */
27
+    class WP_Super_Duper extends WP_Widget {
28
+
29
+        public $version = "1.0.10";
30
+        public $block_code;
31
+        public $options;
32
+        public $base_id;
33
+        public $arguments = array();
34
+        public $instance = array();
35
+        private $class_name;
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
+                // register block
68
+                add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
69
+            }
70
+
71
+            // add the CSS and JS we need ONCE
72
+            global $sd_widget_scripts;
73
+
74
+            if ( ! $sd_widget_scripts ) {
75
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
76
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
77
+                wp_add_inline_style( 'widgets', $this->widget_css() );
78
+
79
+                $sd_widget_scripts = true;
80
+
81
+                // add shortcode insert button once
82
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
83
+                if ( $this->is_preview() ) {
84
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
85
+                    // this makes the insert button work for elementor
86
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
87
+                        $this,
88
+                        'shortcode_insert_button_script'
89
+                    ) ); // for elementor
90
+                }
91
+                // this makes the insert button work for cornerstone
92
+                add_action( 'cornerstone_load_builder', array(
93
+                    $this,
94
+                    'shortcode_insert_button_script'
95
+                ) ); // for cornerstone builder (this is the preview)
96
+
97
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
98
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
99
+
100
+                // add generator text to admin head
101
+                add_action( 'admin_head', array( $this, 'generator' ) );
102
+            }
103
+
104
+            do_action( 'wp_super_duper_widget_init', $options, $this );
105
+        }
106
+
107
+        /**
108
+         * A function to ge the shortcode builder picker html.
109
+         *
110
+         * @param string $editor_id
111
+         *
112
+         * @return string
113
+         */
114
+        public static function get_picker( $editor_id = '' ) {
115
+
116
+            ob_start();
117
+            if ( isset( $_POST['editor_id'] ) ) {
118
+                $editor_id = esc_attr( $_POST['editor_id'] );
119
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
120
+                $editor_id = 'main_content_content_vb_tiny_mce';
121
+            }
122
+
123
+            global $sd_widgets;
124
+            ?>
125 125
 
126 126
 			<div class="sd-shortcode-left-wrap">
127 127
 				<?php
128
-				asort( $sd_widgets );
129
-				if ( ! empty( $sd_widgets ) ) {
130
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
131
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
132
-					foreach ( $sd_widgets as $shortcode => $class ) {
133
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
134
-					}
135
-					echo "</select>";
136
-
137
-				}
138
-				?>
128
+                asort( $sd_widgets );
129
+                if ( ! empty( $sd_widgets ) ) {
130
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
131
+                    echo "<option>" . __( 'Select shortcode' ) . "</option>";
132
+                    foreach ( $sd_widgets as $shortcode => $class ) {
133
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
134
+                    }
135
+                    echo "</select>";
136
+
137
+                }
138
+                ?>
139 139
 				<div class="sd-shortcode-settings"></div>
140 140
 
141 141
 			</div>
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 					<?php if ( $editor_id != '' ) { ?>
147 147
 						<button class="button sd-insert-shortcode-button"
148 148
 						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
149
-							        echo "'" . $editor_id . "'";
150
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
149
+                                    echo "'" . $editor_id . "'";
150
+                                } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
151 151
 					<?php } ?>
152 152
 					<button class="button"
153 153
 					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -155,129 +155,129 @@  discard block
 block discarded – undo
155 155
 			</div>
156 156
 			<?php
157 157
 
158
-			$html = ob_get_clean();
159
-
160
-			if ( wp_doing_ajax() ) {
161
-				echo $html;
162
-				$should_die = true;
163
-
164
-				// some builder get the editor via ajax so we should not die on those ocasions
165
-				$dont_die = array(
166
-					'parent_tag',// WP Bakery
167
-					'avia_request' // enfold
168
-				);
169
-
170
-				foreach ( $dont_die as $request ) {
171
-					if ( isset( $_REQUEST[ $request ] ) ) {
172
-						$should_die = false;
173
-					}
174
-				}
175
-
176
-				if ( $should_die ) {
177
-					wp_die();
178
-				}
179
-
180
-			} else {
181
-				return $html;
182
-			}
183
-
184
-			return '';
185
-
186
-		}
187
-
188
-		/**
189
-		 * Output the version in the admin header.
190
-		 */
191
-		public function generator() {
192
-			echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
193
-		}
194
-
195
-		/**
196
-		 * Get widget settings.
197
-		 *
198
-		 * @since 1.0.0
199
-		 */
200
-		public static function get_widget_settings() {
201
-			global $sd_widgets;
202
-
203
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
204
-			if ( ! $shortcode ) {
205
-				wp_die();
206
-			}
207
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
208
-			if ( ! $widget_args ) {
209
-				wp_die();
210
-			}
211
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
212
-			if ( ! $class_name ) {
213
-				wp_die();
214
-			}
215
-
216
-			// invoke an instance method
217
-			$widget = new $class_name;
218
-
219
-			ob_start();
220
-			$widget->form( array() );
221
-			$form = ob_get_clean();
222
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
223
-			echo "<style>" . $widget->widget_css() . "</style>";
224
-			echo "<script>" . $widget->widget_js() . "</script>";
225
-			?>
158
+            $html = ob_get_clean();
159
+
160
+            if ( wp_doing_ajax() ) {
161
+                echo $html;
162
+                $should_die = true;
163
+
164
+                // some builder get the editor via ajax so we should not die on those ocasions
165
+                $dont_die = array(
166
+                    'parent_tag',// WP Bakery
167
+                    'avia_request' // enfold
168
+                );
169
+
170
+                foreach ( $dont_die as $request ) {
171
+                    if ( isset( $_REQUEST[ $request ] ) ) {
172
+                        $should_die = false;
173
+                    }
174
+                }
175
+
176
+                if ( $should_die ) {
177
+                    wp_die();
178
+                }
179
+
180
+            } else {
181
+                return $html;
182
+            }
183
+
184
+            return '';
185
+
186
+        }
187
+
188
+        /**
189
+         * Output the version in the admin header.
190
+         */
191
+        public function generator() {
192
+            echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
193
+        }
194
+
195
+        /**
196
+         * Get widget settings.
197
+         *
198
+         * @since 1.0.0
199
+         */
200
+        public static function get_widget_settings() {
201
+            global $sd_widgets;
202
+
203
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
204
+            if ( ! $shortcode ) {
205
+                wp_die();
206
+            }
207
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
208
+            if ( ! $widget_args ) {
209
+                wp_die();
210
+            }
211
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
212
+            if ( ! $class_name ) {
213
+                wp_die();
214
+            }
215
+
216
+            // invoke an instance method
217
+            $widget = new $class_name;
218
+
219
+            ob_start();
220
+            $widget->form( array() );
221
+            $form = ob_get_clean();
222
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
223
+            echo "<style>" . $widget->widget_css() . "</style>";
224
+            echo "<script>" . $widget->widget_js() . "</script>";
225
+            ?>
226 226
 			<?php
227
-			wp_die();
228
-		}
229
-
230
-		/**
231
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
232
-		 *
233
-		 * @since 1.0.0
234
-		 *
235
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
236
-		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
237
-		 */
238
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
239
-			global $sd_widgets, $shortcode_insert_button_once;
240
-			if ( $shortcode_insert_button_once ) {
241
-				return;
242
-			}
243
-			add_thickbox();
244
-
245
-
246
-			/**
247
-			 * Cornerstone makes us play dirty tricks :/
248
-			 * 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.
249
-			 */
250
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
251
-				echo '<span id="insert-media-button">';
252
-			}
253
-
254
-			echo self::shortcode_button( 'this', 'true' );
255
-
256
-			// see opening note
257
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
258
-				echo '</span>'; // end #insert-media-button
259
-			}
260
-
261
-			self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
262
-			$shortcode_insert_button_once = true;
263
-		}
264
-
265
-		/**
266
-		 * Gets the shortcode insert button html.
267
-		 *
268
-		 * @param string $id
269
-		 * @param string $search_for_id
270
-		 *
271
-		 * @return mixed
272
-		 */
273
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
274
-			ob_start();
275
-			?>
227
+            wp_die();
228
+        }
229
+
230
+        /**
231
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
232
+         *
233
+         * @since 1.0.0
234
+         *
235
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
236
+         * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
237
+         */
238
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
239
+            global $sd_widgets, $shortcode_insert_button_once;
240
+            if ( $shortcode_insert_button_once ) {
241
+                return;
242
+            }
243
+            add_thickbox();
244
+
245
+
246
+            /**
247
+             * Cornerstone makes us play dirty tricks :/
248
+             * 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.
249
+             */
250
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
251
+                echo '<span id="insert-media-button">';
252
+            }
253
+
254
+            echo self::shortcode_button( 'this', 'true' );
255
+
256
+            // see opening note
257
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
258
+                echo '</span>'; // end #insert-media-button
259
+            }
260
+
261
+            self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
262
+            $shortcode_insert_button_once = true;
263
+        }
264
+
265
+        /**
266
+         * Gets the shortcode insert button html.
267
+         *
268
+         * @param string $id
269
+         * @param string $search_for_id
270
+         *
271
+         * @return mixed
272
+         */
273
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
274
+            ob_start();
275
+            ?>
276 276
 			<span class="sd-lable-shortcode-inserter">
277 277
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
278
-				if ( $search_for_id ) {
279
-					echo "," . $search_for_id;
280
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
278
+                if ( $search_for_id ) {
279
+                    echo "," . $search_for_id;
280
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
281 281
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
282 282
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
283 283
 					      class="dashicons dashicons-screenoptions"></span>
@@ -288,21 +288,21 @@  discard block
 block discarded – undo
288 288
 			</span>
289 289
 
290 290
 			<?php
291
-			$html = ob_get_clean();
292
-
293
-			// remove line breaks so we can use it in js
294
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
295
-		}
296
-
297
-		/**
298
-		 * Makes SD work with the siteOrigin page builder.
299
-		 *
300
-		 * @since 1.0.6
301
-		 * @return mixed
302
-		 */
303
-		public static function siteorigin_js() {
304
-			ob_start();
305
-			?>
291
+            $html = ob_get_clean();
292
+
293
+            // remove line breaks so we can use it in js
294
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
295
+        }
296
+
297
+        /**
298
+         * Makes SD work with the siteOrigin page builder.
299
+         *
300
+         * @since 1.0.6
301
+         * @return mixed
302
+         */
303
+        public static function siteorigin_js() {
304
+            ob_start();
305
+            ?>
306 306
 			<script>
307 307
 				/**
308 308
 				 * Check a form to see what items shoudl be shown or hidden.
@@ -380,28 +380,28 @@  discard block
 block discarded – undo
380 380
 				});
381 381
 			</script>
382 382
 			<?php
383
-			$output = ob_get_clean();
383
+            $output = ob_get_clean();
384 384
 
385
-			/*
385
+            /*
386 386
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
387 387
 			 */
388 388
 
389
-			return str_replace( array(
390
-				'<script>',
391
-				'</script>'
392
-			), '', $output );
393
-		}
394
-
395
-		/**
396
-		 * Output the JS and CSS for the shortcode insert button.
397
-		 *
398
-		 * @since 1.0.6
399
-		 *
400
-		 * @param string $editor_id
401
-		 * @param string $insert_shortcode_function
402
-		 */
403
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
404
-			?>
389
+            return str_replace( array(
390
+                '<script>',
391
+                '</script>'
392
+            ), '', $output );
393
+        }
394
+
395
+        /**
396
+         * Output the JS and CSS for the shortcode insert button.
397
+         *
398
+         * @since 1.0.6
399
+         *
400
+         * @param string $editor_id
401
+         * @param string $insert_shortcode_function
402
+         */
403
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
404
+            ?>
405 405
 			<style>
406 406
 				.sd-shortcode-left-wrap {
407 407
 					float: left;
@@ -520,22 +520,22 @@  discard block
 block discarded – undo
520 520
 				}
521 521
 			</style>
522 522
 			<?php
523
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
524
-				echo "<script>" . self::siteorigin_js() . "</script>";
525
-			}
526
-			?>
523
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
524
+                echo "<script>" . self::siteorigin_js() . "</script>";
525
+            }
526
+            ?>
527 527
 			<script>
528 528
 				<?php
529
-				if(! empty( $insert_shortcode_function )){
530
-					echo $insert_shortcode_function;
531
-				}else{
532
-
533
-				/**
534
-				 * Function for super duper insert shortcode.
535
-				 *
536
-				 * @since 1.0.0
537
-				 */
538
-				?>
529
+                if(! empty( $insert_shortcode_function )){
530
+                    echo $insert_shortcode_function;
531
+                }else{
532
+
533
+                /**
534
+                 * Function for super duper insert shortcode.
535
+                 *
536
+                 * @since 1.0.0
537
+                 */
538
+                ?>
539 539
 				function sd_insert_shortcode($editor_id) {
540 540
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
541 541
 					if ($shortcode) {
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
 						if (!$editor_id) {
544 544
 
545 545
 							<?php
546
-							if ( isset( $_REQUEST['et_fb'] ) ) {
547
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
548
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
549
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
550
-							} else {
551
-								echo '$editor_id = "#wp-content-editor-container textarea";';
552
-							}
553
-							?>
546
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
547
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
548
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
549
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
550
+                            } else {
551
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
552
+                            }
553
+                            ?>
554 554
 						} else {
555 555
 							$editor_id = '#' + $editor_id;
556 556
 						}
@@ -852,16 +852,16 @@  discard block
 block discarded – undo
852 852
 			</script>
853 853
 
854 854
 			<?php
855
-		}
856
-
857
-		/**
858
-		 * Gets some CSS for the widgets screen.
859
-		 *
860
-		 * @return mixed
861
-		 */
862
-		public function widget_css() {
863
-			ob_start();
864
-			?>
855
+        }
856
+
857
+        /**
858
+         * Gets some CSS for the widgets screen.
859
+         *
860
+         * @return mixed
861
+         */
862
+        public function widget_css() {
863
+            ob_start();
864
+            ?>
865 865
 			<style>
866 866
 				.sd-advanced-setting {
867 867
 					display: none;
@@ -882,26 +882,26 @@  discard block
 block discarded – undo
882 882
 				}
883 883
 			</style>
884 884
 			<?php
885
-			$output = ob_get_clean();
885
+            $output = ob_get_clean();
886 886
 
887
-			/*
887
+            /*
888 888
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
889 889
 			 */
890 890
 
891
-			return str_replace( array(
892
-				'<style>',
893
-				'</style>'
894
-			), '', $output );
895
-		}
896
-
897
-		/**
898
-		 * Gets some JS for the widgets screen.
899
-		 *
900
-		 * @return mixed
901
-		 */
902
-		public function widget_js() {
903
-			ob_start();
904
-			?>
891
+            return str_replace( array(
892
+                '<style>',
893
+                '</style>'
894
+            ), '', $output );
895
+        }
896
+
897
+        /**
898
+         * Gets some JS for the widgets screen.
899
+         *
900
+         * @return mixed
901
+         */
902
+        public function widget_js() {
903
+            ob_start();
904
+            ?>
905 905
 			<script>
906 906
 
907 907
 				/**
@@ -1056,302 +1056,302 @@  discard block
 block discarded – undo
1056 1056
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1057 1057
 			</script>
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
-				'<script>',
1067
-				'</script>'
1068
-			), '', $output );
1069
-		}
1070
-
1071
-
1072
-		/**
1073
-		 * Set the name from the argument key.
1074
-		 *
1075
-		 * @param $options
1076
-		 *
1077
-		 * @return mixed
1078
-		 */
1079
-		private function add_name_from_key( $options, $arguments = false ) {
1080
-			if ( ! empty( $options['arguments'] ) ) {
1081
-				foreach ( $options['arguments'] as $key => $val ) {
1082
-					$options['arguments'][ $key ]['name'] = $key;
1083
-				}
1084
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1085
-				foreach ( $options as $key => $val ) {
1086
-					$options[ $key ]['name'] = $key;
1087
-				}
1088
-			}
1089
-
1090
-			return $options;
1091
-		}
1092
-
1093
-		/**
1094
-		 * Register the parent shortcode.
1095
-		 *
1096
-		 * @since 1.0.0
1097
-		 */
1098
-		public function register_shortcode() {
1099
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1100
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1101
-		}
1102
-
1103
-		/**
1104
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1105
-		 *
1106
-		 * @since 1.0.0
1107
-		 */
1108
-		public static function render_shortcode() {
1109
-
1110
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1111
-			if ( ! current_user_can( 'manage_options' ) ) {
1112
-				wp_die();
1113
-			}
1114
-
1115
-			// we might need the $post value here so lets set it.
1116
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1117
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1118
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1119
-					global $post;
1120
-					$post = $post_obj;
1121
-				}
1122
-			}
1123
-
1124
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1125
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1126
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1127
-				$attributes       = '';
1128
-				if ( ! empty( $attributes_array ) ) {
1129
-					foreach ( $attributes_array as $key => $value ) {
1130
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1131
-					}
1132
-				}
1133
-
1134
-				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1135
-
1136
-				echo do_shortcode( $shortcode );
1137
-
1138
-			}
1139
-			wp_die();
1140
-		}
1141
-
1142
-		/**
1143
-		 * Output the shortcode.
1144
-		 *
1145
-		 * @param array $args
1146
-		 * @param string $content
1147
-		 *
1148
-		 * @return string
1149
-		 */
1150
-		public function shortcode_output( $args = array(), $content = '' ) {
1151
-			$args = self::argument_values( $args );
1152
-
1153
-			// add extra argument so we know its a output to gutenberg
1154
-			//$args
1155
-			$args = $this->string_to_bool( $args );
1156
-
1157
-
1158
-			$calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1159
-
1160
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1161
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1162
-
1163
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1164
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1165
-
1166
-			$shortcode_args = array();
1167
-			$output         = '';
1168
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1169
-			$main_content   = $this->output( $args, $shortcode_args, $content );
1170
-			if ( $main_content && ! $no_wrap ) {
1171
-				// wrap the shortcode in a dive with the same class as the widget
1172
-				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
1173
-				if ( ! empty( $args['title'] ) ) {
1174
-					// if its a shortcode and there is a title try to grab the title wrappers
1175
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1176
-					if ( empty( $instance ) ) {
1177
-						global $wp_registered_sidebars;
1178
-						if ( ! empty( $wp_registered_sidebars ) ) {
1179
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1180
-								if ( ! empty( $sidebar['before_title'] ) ) {
1181
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1182
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1183
-									break;
1184
-								}
1185
-							}
1186
-						}
1187
-					}
1188
-					$output .= $this->output_title( $shortcode_args, $args );
1189
-				}
1190
-				$output .= $main_content;
1191
-				$output .= '</div>';
1192
-			} elseif ( $main_content && $no_wrap ) {
1193
-				$output .= $main_content;
1194
-			}
1195
-
1196
-			// if preview show a placeholder if empty
1197
-			if ( $this->is_preview() && $output == '' ) {
1198
-				$output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1199
-			}
1200
-
1201
-			return $output;
1202
-		}
1203
-
1204
-		/**
1205
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1206
-		 *
1207
-		 * @param string $name
1208
-		 *
1209
-		 * @return string
1210
-		 */
1211
-		public function preview_placeholder_text( $name = '' ) {
1212
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1213
-		}
1214
-
1215
-		/**
1216
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1217
-		 *
1218
-		 * @param $options
1219
-		 *
1220
-		 * @return mixed
1221
-		 */
1222
-		public function string_to_bool( $options ) {
1223
-			// convert bool strings to booleans
1224
-			foreach ( $options as $key => $val ) {
1225
-				if ( $val == 'false' ) {
1226
-					$options[ $key ] = false;
1227
-				} elseif ( $val == 'true' ) {
1228
-					$options[ $key ] = true;
1229
-				}
1230
-			}
1231
-
1232
-			return $options;
1233
-		}
1234
-
1235
-		/**
1236
-		 * Get the argument values that are also filterable.
1237
-		 *
1238
-		 * @param $instance
1239
-		 *
1240
-		 * @return array
1241
-		 */
1242
-		public function argument_values( $instance ) {
1243
-			$argument_values = array();
1244
-
1245
-			// set widget instance
1246
-			$this->instance = $instance;
1247
-
1248
-			if ( empty( $this->arguments ) ) {
1249
-				$this->arguments = $this->get_arguments();
1250
-			}
1251
-
1252
-			if ( ! empty( $this->arguments ) ) {
1253
-				foreach ( $this->arguments as $key => $args ) {
1254
-					// set the input name from the key
1255
-					$args['name'] = $key;
1256
-					//
1257
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1258
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1259
-						$argument_values[ $key ] = $args['default'];
1260
-					}
1261
-				}
1262
-			}
1263
-
1264
-			return $argument_values;
1265
-		}
1266
-
1267
-		/**
1268
-		 * Set arguments in super duper.
1269
-		 *
1270
-		 * @since 1.0.0
1271
-		 *
1272
-		 * @return array Set arguments.
1273
-		 */
1274
-		public function set_arguments() {
1275
-			return $this->arguments;
1276
-		}
1277
-
1278
-		/**
1279
-		 * Get arguments in super duper.
1280
-		 *
1281
-		 * @since 1.0.0
1282
-		 *
1283
-		 * @return array Get arguments.
1284
-		 */
1285
-		public function get_arguments() {
1286
-			if ( empty( $this->arguments ) ) {
1287
-				$this->arguments = $this->set_arguments();
1288
-			}
1289
-
1290
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1291
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1292
-
1293
-			return $this->arguments;
1294
-		}
1295
-
1296
-		/**
1297
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1298
-		 *
1299
-		 * @param array $args
1300
-		 * @param array $widget_args
1301
-		 * @param string $content
1302
-		 */
1303
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1304
-
1305
-		}
1306
-
1307
-		/**
1308
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1309
-		 */
1310
-		public function register_block() {
1311
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1312
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1313
-
1314
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1315
-
1316
-			}
1317
-		}
1318
-
1319
-		/**
1320
-		 * Check if we need to show advanced options.
1321
-		 *
1322
-		 * @return bool
1323
-		 */
1324
-		public function block_show_advanced() {
1325
-
1326
-			$show      = false;
1327
-			$arguments = $this->arguments;
1328
-
1329
-			if ( empty( $arguments ) ) {
1330
-				$arguments = $this->get_arguments();
1331
-			}
1332
-
1333
-			if ( ! empty( $arguments ) ) {
1334
-				foreach ( $arguments as $argument ) {
1335
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1336
-						$show = true;
1337
-					}
1338
-				}
1339
-			}
1340
-
1341
-			return $show;
1342
-		}
1343
-
1344
-
1345
-		/**
1346
-		 * Output the JS for building the dynamic Guntenberg block.
1347
-		 *
1348
-		 * @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.
1349
-		 * @since 1.0.9 Save numbers as numbers and not strings.
1350
-		 * @return mixed
1351
-		 */
1352
-		public function block() {
1353
-			ob_start();
1354
-			?>
1065
+            return str_replace( array(
1066
+                '<script>',
1067
+                '</script>'
1068
+            ), '', $output );
1069
+        }
1070
+
1071
+
1072
+        /**
1073
+         * Set the name from the argument key.
1074
+         *
1075
+         * @param $options
1076
+         *
1077
+         * @return mixed
1078
+         */
1079
+        private function add_name_from_key( $options, $arguments = false ) {
1080
+            if ( ! empty( $options['arguments'] ) ) {
1081
+                foreach ( $options['arguments'] as $key => $val ) {
1082
+                    $options['arguments'][ $key ]['name'] = $key;
1083
+                }
1084
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1085
+                foreach ( $options as $key => $val ) {
1086
+                    $options[ $key ]['name'] = $key;
1087
+                }
1088
+            }
1089
+
1090
+            return $options;
1091
+        }
1092
+
1093
+        /**
1094
+         * Register the parent shortcode.
1095
+         *
1096
+         * @since 1.0.0
1097
+         */
1098
+        public function register_shortcode() {
1099
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1100
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1101
+        }
1102
+
1103
+        /**
1104
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1105
+         *
1106
+         * @since 1.0.0
1107
+         */
1108
+        public static function render_shortcode() {
1109
+
1110
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1111
+            if ( ! current_user_can( 'manage_options' ) ) {
1112
+                wp_die();
1113
+            }
1114
+
1115
+            // we might need the $post value here so lets set it.
1116
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1117
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1118
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1119
+                    global $post;
1120
+                    $post = $post_obj;
1121
+                }
1122
+            }
1123
+
1124
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1125
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1126
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1127
+                $attributes       = '';
1128
+                if ( ! empty( $attributes_array ) ) {
1129
+                    foreach ( $attributes_array as $key => $value ) {
1130
+                        $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1131
+                    }
1132
+                }
1133
+
1134
+                $shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1135
+
1136
+                echo do_shortcode( $shortcode );
1137
+
1138
+            }
1139
+            wp_die();
1140
+        }
1141
+
1142
+        /**
1143
+         * Output the shortcode.
1144
+         *
1145
+         * @param array $args
1146
+         * @param string $content
1147
+         *
1148
+         * @return string
1149
+         */
1150
+        public function shortcode_output( $args = array(), $content = '' ) {
1151
+            $args = self::argument_values( $args );
1152
+
1153
+            // add extra argument so we know its a output to gutenberg
1154
+            //$args
1155
+            $args = $this->string_to_bool( $args );
1156
+
1157
+
1158
+            $calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1159
+
1160
+            $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1161
+            $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1162
+
1163
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1164
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1165
+
1166
+            $shortcode_args = array();
1167
+            $output         = '';
1168
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1169
+            $main_content   = $this->output( $args, $shortcode_args, $content );
1170
+            if ( $main_content && ! $no_wrap ) {
1171
+                // wrap the shortcode in a dive with the same class as the widget
1172
+                $output .= '<div class="' . $calss . '" ' . $attrs . '>';
1173
+                if ( ! empty( $args['title'] ) ) {
1174
+                    // if its a shortcode and there is a title try to grab the title wrappers
1175
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1176
+                    if ( empty( $instance ) ) {
1177
+                        global $wp_registered_sidebars;
1178
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1179
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1180
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1181
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1182
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1183
+                                    break;
1184
+                                }
1185
+                            }
1186
+                        }
1187
+                    }
1188
+                    $output .= $this->output_title( $shortcode_args, $args );
1189
+                }
1190
+                $output .= $main_content;
1191
+                $output .= '</div>';
1192
+            } elseif ( $main_content && $no_wrap ) {
1193
+                $output .= $main_content;
1194
+            }
1195
+
1196
+            // if preview show a placeholder if empty
1197
+            if ( $this->is_preview() && $output == '' ) {
1198
+                $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1199
+            }
1200
+
1201
+            return $output;
1202
+        }
1203
+
1204
+        /**
1205
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1206
+         *
1207
+         * @param string $name
1208
+         *
1209
+         * @return string
1210
+         */
1211
+        public function preview_placeholder_text( $name = '' ) {
1212
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1213
+        }
1214
+
1215
+        /**
1216
+         * Sometimes booleans values can be turned to strings, so we fix that.
1217
+         *
1218
+         * @param $options
1219
+         *
1220
+         * @return mixed
1221
+         */
1222
+        public function string_to_bool( $options ) {
1223
+            // convert bool strings to booleans
1224
+            foreach ( $options as $key => $val ) {
1225
+                if ( $val == 'false' ) {
1226
+                    $options[ $key ] = false;
1227
+                } elseif ( $val == 'true' ) {
1228
+                    $options[ $key ] = true;
1229
+                }
1230
+            }
1231
+
1232
+            return $options;
1233
+        }
1234
+
1235
+        /**
1236
+         * Get the argument values that are also filterable.
1237
+         *
1238
+         * @param $instance
1239
+         *
1240
+         * @return array
1241
+         */
1242
+        public function argument_values( $instance ) {
1243
+            $argument_values = array();
1244
+
1245
+            // set widget instance
1246
+            $this->instance = $instance;
1247
+
1248
+            if ( empty( $this->arguments ) ) {
1249
+                $this->arguments = $this->get_arguments();
1250
+            }
1251
+
1252
+            if ( ! empty( $this->arguments ) ) {
1253
+                foreach ( $this->arguments as $key => $args ) {
1254
+                    // set the input name from the key
1255
+                    $args['name'] = $key;
1256
+                    //
1257
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1258
+                    if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1259
+                        $argument_values[ $key ] = $args['default'];
1260
+                    }
1261
+                }
1262
+            }
1263
+
1264
+            return $argument_values;
1265
+        }
1266
+
1267
+        /**
1268
+         * Set arguments in super duper.
1269
+         *
1270
+         * @since 1.0.0
1271
+         *
1272
+         * @return array Set arguments.
1273
+         */
1274
+        public function set_arguments() {
1275
+            return $this->arguments;
1276
+        }
1277
+
1278
+        /**
1279
+         * Get arguments in super duper.
1280
+         *
1281
+         * @since 1.0.0
1282
+         *
1283
+         * @return array Get arguments.
1284
+         */
1285
+        public function get_arguments() {
1286
+            if ( empty( $this->arguments ) ) {
1287
+                $this->arguments = $this->set_arguments();
1288
+            }
1289
+
1290
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1291
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1292
+
1293
+            return $this->arguments;
1294
+        }
1295
+
1296
+        /**
1297
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1298
+         *
1299
+         * @param array $args
1300
+         * @param array $widget_args
1301
+         * @param string $content
1302
+         */
1303
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1304
+
1305
+        }
1306
+
1307
+        /**
1308
+         * Add the dynamic block code inline when the wp-block in enqueued.
1309
+         */
1310
+        public function register_block() {
1311
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1312
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1313
+
1314
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1315
+
1316
+            }
1317
+        }
1318
+
1319
+        /**
1320
+         * Check if we need to show advanced options.
1321
+         *
1322
+         * @return bool
1323
+         */
1324
+        public function block_show_advanced() {
1325
+
1326
+            $show      = false;
1327
+            $arguments = $this->arguments;
1328
+
1329
+            if ( empty( $arguments ) ) {
1330
+                $arguments = $this->get_arguments();
1331
+            }
1332
+
1333
+            if ( ! empty( $arguments ) ) {
1334
+                foreach ( $arguments as $argument ) {
1335
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1336
+                        $show = true;
1337
+                    }
1338
+                }
1339
+            }
1340
+
1341
+            return $show;
1342
+        }
1343
+
1344
+
1345
+        /**
1346
+         * Output the JS for building the dynamic Guntenberg block.
1347
+         *
1348
+         * @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.
1349
+         * @since 1.0.9 Save numbers as numbers and not strings.
1350
+         * @return mixed
1351
+         */
1352
+        public function block() {
1353
+            ob_start();
1354
+            ?>
1355 1355
 			<script>
1356 1356
 				/**
1357 1357
 				 * BLOCK: Basic
@@ -1390,76 +1390,76 @@  discard block
 block discarded – undo
1390 1390
 						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/.
1391 1391
 						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.
1392 1392
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
1393
-						echo "keywords : " . $this->options['block-keywords'] . ",";
1394
-					}?>
1393
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
1394
+                    }?>
1395 1395
 
1396 1396
 						<?php
1397 1397
 
1398
-						$show_advanced = $this->block_show_advanced();
1399
-
1400
-						$show_alignment = false;
1401
-
1402
-						if ( ! empty( $this->arguments ) ) {
1403
-							echo "attributes : {";
1404
-
1405
-							if ( $show_advanced ) {
1406
-								echo "show_advanced: {";
1407
-								echo "	type: 'boolean',";
1408
-								echo "  default: false,";
1409
-								echo "},";
1410
-							}
1411
-
1412
-							// block wrap element
1413
-							if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1414
-								echo "block_wrap: {";
1415
-								echo "	type: 'string',";
1416
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1417
-								echo "},";
1418
-							}
1419
-
1420
-
1421
-							foreach ( $this->arguments as $key => $args ) {
1422
-
1423
-								// set if we should show alignment
1424
-								if ( $key == 'alignment' ) {
1425
-									$show_alignment = true;
1426
-								}
1427
-
1428
-								$extra = '';
1429
-
1430
-								if ( $args['type'] == 'checkbox' ) {
1431
-									$type    = 'boolean';
1432
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1433
-								} elseif ( $args['type'] == 'number' ) {
1434
-									$type    = 'number';
1435
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1436
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1437
-									$type = 'array';
1438
-									if ( is_array( $args['default'] ) ) {
1439
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1440
-									} else {
1441
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1442
-									}
1443
-								} elseif ( $args['type'] == 'multiselect' ) {
1444
-									$type    = 'array';
1445
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1446
-								} else {
1447
-									$type    = 'string';
1448
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1449
-								}
1450
-								echo $key . " : {";
1451
-								echo "type : '$type',";
1452
-								echo "default : $default,";
1453
-								echo "},";
1454
-							}
1455
-
1456
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
1457
-
1458
-							echo "},";
1459
-
1460
-						}
1461
-
1462
-						?>
1398
+                        $show_advanced = $this->block_show_advanced();
1399
+
1400
+                        $show_alignment = false;
1401
+
1402
+                        if ( ! empty( $this->arguments ) ) {
1403
+                            echo "attributes : {";
1404
+
1405
+                            if ( $show_advanced ) {
1406
+                                echo "show_advanced: {";
1407
+                                echo "	type: 'boolean',";
1408
+                                echo "  default: false,";
1409
+                                echo "},";
1410
+                            }
1411
+
1412
+                            // block wrap element
1413
+                            if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1414
+                                echo "block_wrap: {";
1415
+                                echo "	type: 'string',";
1416
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1417
+                                echo "},";
1418
+                            }
1419
+
1420
+
1421
+                            foreach ( $this->arguments as $key => $args ) {
1422
+
1423
+                                // set if we should show alignment
1424
+                                if ( $key == 'alignment' ) {
1425
+                                    $show_alignment = true;
1426
+                                }
1427
+
1428
+                                $extra = '';
1429
+
1430
+                                if ( $args['type'] == 'checkbox' ) {
1431
+                                    $type    = 'boolean';
1432
+                                    $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1433
+                                } elseif ( $args['type'] == 'number' ) {
1434
+                                    $type    = 'number';
1435
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1436
+                                } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1437
+                                    $type = 'array';
1438
+                                    if ( is_array( $args['default'] ) ) {
1439
+                                        $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1440
+                                    } else {
1441
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1442
+                                    }
1443
+                                } elseif ( $args['type'] == 'multiselect' ) {
1444
+                                    $type    = 'array';
1445
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1446
+                                } else {
1447
+                                    $type    = 'string';
1448
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1449
+                                }
1450
+                                echo $key . " : {";
1451
+                                echo "type : '$type',";
1452
+                                echo "default : $default,";
1453
+                                echo "},";
1454
+                            }
1455
+
1456
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
1457
+
1458
+                            echo "},";
1459
+
1460
+                        }
1461
+
1462
+                        ?>
1463 1463
 
1464 1464
 						// The "edit" property must be a valid function.
1465 1465
 						edit: function (props) {
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
 										'shortcode': '<?php echo $this->options['base_id'];?>',
1479 1479
 										'attributes': props.attributes,
1480 1480
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1481
-										echo $post->ID;
1482
-									}?>,
1481
+                                        echo $post->ID;
1482
+                                    }?>,
1483 1483
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1484 1484
 									};
1485 1485
 
@@ -1526,10 +1526,10 @@  discard block
 block discarded – undo
1526 1526
 
1527 1527
 									<?php
1528 1528
 
1529
-									if(! empty( $this->arguments )){
1529
+                                    if(! empty( $this->arguments )){
1530 1530
 
1531
-									if ( $show_advanced ) {
1532
-									?>
1531
+                                    if ( $show_advanced ) {
1532
+                                    ?>
1533 1533
 									el(
1534 1534
 										wp.components.ToggleControl,
1535 1535
 										{
@@ -1542,73 +1542,73 @@  discard block
 block discarded – undo
1542 1542
 									),
1543 1543
 									<?php
1544 1544
 
1545
-									}
1546
-
1547
-									foreach($this->arguments as $key => $args){
1548
-									$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1549
-									$options = '';
1550
-									$extra = '';
1551
-									$require = '';
1552
-									$onchange = "props.setAttributes({ $key: $key } )";
1553
-									$value = "props.attributes.$key";
1554
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1555
-									if ( in_array( $args['type'], $text_type ) ) {
1556
-										$type = 'TextControl';
1557
-										// Save numbers as numbers and not strings
1558
-										if ( $args['type'] == 'number' ) {
1559
-											$onchange = "props.setAttributes({ $key: Number($key) } )";
1560
-										}
1561
-									}
1545
+                                    }
1546
+
1547
+                                    foreach($this->arguments as $key => $args){
1548
+                                    $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1549
+                                    $options = '';
1550
+                                    $extra = '';
1551
+                                    $require = '';
1552
+                                    $onchange = "props.setAttributes({ $key: $key } )";
1553
+                                    $value = "props.attributes.$key";
1554
+                                    $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1555
+                                    if ( in_array( $args['type'], $text_type ) ) {
1556
+                                        $type = 'TextControl';
1557
+                                        // Save numbers as numbers and not strings
1558
+                                        if ( $args['type'] == 'number' ) {
1559
+                                            $onchange = "props.setAttributes({ $key: Number($key) } )";
1560
+                                        }
1561
+                                    }
1562 1562
 //									elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we may have to add our own https://github.com/WordPress/gutenberg/issues/14378
1563 1563
 //										$type = 'ColorPicker';
1564 1564
 //									}
1565
-									elseif ( $args['type'] == 'checkbox' ) {
1566
-										$type = 'CheckboxControl';
1567
-										$extra .= "checked: props.attributes.$key,";
1568
-										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1569
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1570
-										$type = 'SelectControl';
1571
-										if ( ! empty( $args['options'] ) ) {
1572
-											$options .= "options  : [";
1573
-											foreach ( $args['options'] as $option_val => $option_label ) {
1574
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1575
-											}
1576
-											$options .= "],";
1577
-										}
1578
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1579
-											$extra .= ' multiple: true, ';
1580
-											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1581
-											//$value = "['edit', 'delete']";
1582
-										}
1583
-									} elseif ( $args['type'] == 'alignment' ) {
1584
-										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1585
-									} else {
1586
-										continue;// if we have not implemented the control then don't break the JS.
1587
-									}
1588
-
1589
-									// add show only if advanced
1590
-									if ( ! empty( $args['advanced'] ) ) {
1591
-										echo "props.attributes.show_advanced && ";
1592
-									}
1593
-									// add setting require if defined
1594
-									if ( ! empty( $args['element_require'] ) ) {
1595
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1596
-									}
1597
-									?>
1565
+                                    elseif ( $args['type'] == 'checkbox' ) {
1566
+                                        $type = 'CheckboxControl';
1567
+                                        $extra .= "checked: props.attributes.$key,";
1568
+                                        $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1569
+                                    } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1570
+                                        $type = 'SelectControl';
1571
+                                        if ( ! empty( $args['options'] ) ) {
1572
+                                            $options .= "options  : [";
1573
+                                            foreach ( $args['options'] as $option_val => $option_label ) {
1574
+                                                $options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1575
+                                            }
1576
+                                            $options .= "],";
1577
+                                        }
1578
+                                        if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1579
+                                            $extra .= ' multiple: true, ';
1580
+                                            //$onchange = "props.setAttributes({ $key: ['edit'] } )";
1581
+                                            //$value = "['edit', 'delete']";
1582
+                                        }
1583
+                                    } elseif ( $args['type'] == 'alignment' ) {
1584
+                                        $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1585
+                                    } else {
1586
+                                        continue;// if we have not implemented the control then don't break the JS.
1587
+                                    }
1588
+
1589
+                                    // add show only if advanced
1590
+                                    if ( ! empty( $args['advanced'] ) ) {
1591
+                                        echo "props.attributes.show_advanced && ";
1592
+                                    }
1593
+                                    // add setting require if defined
1594
+                                    if ( ! empty( $args['element_require'] ) ) {
1595
+                                        echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1596
+                                    }
1597
+                                    ?>
1598 1598
 									el(
1599 1599
 										wp.components.<?php echo esc_attr( $type );?>,
1600 1600
 										{
1601 1601
 											label: '<?php echo esc_attr( $args['title'] );?>',
1602 1602
 											help: '<?php if ( isset( $args['desc'] ) ) {
1603
-												echo esc_attr( $args['desc'] );
1604
-											}?>',
1603
+                                                echo esc_attr( $args['desc'] );
1604
+                                            }?>',
1605 1605
 											value: <?php echo $value;?>,
1606 1606
 											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1607
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1608
-										}?>
1607
+                                            echo "type: '" . esc_attr( $args['type'] ) . "',";
1608
+                                        }?>
1609 1609
 											<?php if ( ! empty( $args['placeholder'] ) ) {
1610
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1611
-										}?>
1610
+                                            echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1611
+                                        }?>
1612 1612
 											<?php echo $options;?>
1613 1613
 											<?php echo $extra;?>
1614 1614
 											<?php echo $custom_attributes;?>
@@ -1618,27 +1618,27 @@  discard block
 block discarded – undo
1618 1618
 										}
1619 1619
 									),
1620 1620
 									<?php
1621
-									}
1622
-									}
1623
-									?>
1621
+                                    }
1622
+                                    }
1623
+                                    ?>
1624 1624
 
1625 1625
 								),
1626 1626
 
1627 1627
 								<?php
1628
-								// If the user sets block-output array then build it
1629
-								if ( ! empty( $this->options['block-output'] ) ) {
1630
-								$this->block_element( $this->options['block-output'] );
1631
-							}else{
1632
-								// if no block-output is set then we try and get the shortcode html output via ajax.
1633
-								?>
1628
+                                // If the user sets block-output array then build it
1629
+                                if ( ! empty( $this->options['block-output'] ) ) {
1630
+                                $this->block_element( $this->options['block-output'] );
1631
+                            }else{
1632
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
1633
+                                ?>
1634 1634
 								el('div', {
1635 1635
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
1636 1636
 									className: props.className,
1637 1637
 									style: {'min-height': '30px'}
1638 1638
 								})
1639 1639
 								<?php
1640
-								}
1641
-								?>
1640
+                                }
1641
+                                ?>
1642 1642
 							]; // end return
1643 1643
 						},
1644 1644
 
@@ -1655,17 +1655,17 @@  discard block
 block discarded – undo
1655 1655
 							var content = "[<?php echo $this->options['base_id'];?>";
1656 1656
 							<?php
1657 1657
 
1658
-							if(! empty( $this->arguments )){
1659
-							foreach($this->arguments as $key => $args){
1660
-							?>
1658
+                            if(! empty( $this->arguments )){
1659
+                            foreach($this->arguments as $key => $args){
1660
+                            ?>
1661 1661
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1662 1662
 								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1663 1663
 							}
1664 1664
 							<?php
1665
-							}
1666
-							}
1665
+                            }
1666
+                            }
1667 1667
 
1668
-							?>
1668
+                            ?>
1669 1669
 							content += "]";
1670 1670
 
1671 1671
 
@@ -1694,456 +1694,456 @@  discard block
 block discarded – undo
1694 1694
 				})();
1695 1695
 			</script>
1696 1696
 			<?php
1697
-			$output = ob_get_clean();
1697
+            $output = ob_get_clean();
1698 1698
 
1699
-			/*
1699
+            /*
1700 1700
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1701 1701
 			 */
1702 1702
 
1703
-			return str_replace( array(
1704
-				'<script>',
1705
-				'</script>'
1706
-			), '', $output );
1707
-		}
1708
-
1709
-		/**
1710
-		 * Convert an array of attributes to block string.
1711
-		 *
1712
-		 * @todo there is prob a faster way to do this, also we could add some validation here.
1713
-		 *
1714
-		 * @param $custom_attributes
1715
-		 *
1716
-		 * @return string
1717
-		 */
1718
-		public function array_to_attributes( $custom_attributes, $html = false ) {
1719
-			$attributes = '';
1720
-			if ( ! empty( $custom_attributes ) ) {
1721
-
1722
-				if ( $html ) {
1723
-					foreach ( $custom_attributes as $key => $val ) {
1724
-						$attributes .= " $key='$val' ";
1725
-					}
1726
-				} else {
1727
-					foreach ( $custom_attributes as $key => $val ) {
1728
-						$attributes .= "'$key': '$val',";
1729
-					}
1730
-				}
1731
-			}
1732
-
1733
-			return $attributes;
1734
-		}
1735
-
1736
-		/**
1737
-		 * A self looping function to create the output for JS block elements.
1738
-		 *
1739
-		 * This is what is output in the WP Editor visual view.
1740
-		 *
1741
-		 * @param $args
1742
-		 */
1743
-		public function block_element( $args ) {
1744
-
1745
-
1746
-			if ( ! empty( $args ) ) {
1747
-				foreach ( $args as $element => $new_args ) {
1748
-
1749
-					if ( is_array( $new_args ) ) { // its an element
1750
-
1751
-
1752
-						if ( isset( $new_args['element'] ) ) {
1753
-
1754
-							if ( isset( $new_args['element_require'] ) ) {
1755
-								echo str_replace( array(
1756
-										"'+",
1757
-										"+'"
1758
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1759
-								unset( $new_args['element_require'] );
1760
-							}
1761
-
1762
-							echo "\n el( '" . $new_args['element'] . "', {";
1763
-
1764
-							// get the attributes
1765
-							foreach ( $new_args as $new_key => $new_value ) {
1766
-
1767
-
1768
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1769
-									// do nothing
1770
-								} else {
1771
-									echo $this->block_element( array( $new_key => $new_value ) );
1772
-								}
1773
-							}
1774
-
1775
-							echo "},";// end attributes
1776
-
1777
-							// get the content
1778
-							$first_item = 0;
1779
-							foreach ( $new_args as $new_key => $new_value ) {
1780
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1781
-
1782
-									if ( $new_key === 'content' ) {
1783
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1784
-									}
1785
-
1786
-									if ( is_array( $new_value ) ) {
1787
-
1788
-										if ( isset( $new_value['element_require'] ) ) {
1789
-											echo str_replace( array(
1790
-													"'+",
1791
-													"+'"
1792
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1793
-											unset( $new_value['element_require'] );
1794
-										}
1795
-
1796
-										if ( isset( $new_value['element_repeat'] ) ) {
1797
-											$x = 1;
1798
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1799
-												$this->block_element( array( '' => $new_value ) );
1800
-												$x ++;
1801
-											}
1802
-										} else {
1803
-											$this->block_element( array( '' => $new_value ) );
1804
-										}
1805
-									}
1806
-									$first_item ++;
1807
-								}
1808
-							}
1809
-
1810
-							echo ")";// end content
1811
-
1812
-							echo ", \n";
1813
-
1814
-						}
1815
-					} else {
1816
-
1817
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1818
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1819
-						} elseif ( $element == 'style' ) {
1820
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1821
-						} else {
1822
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1823
-						}
1824
-
1825
-					}
1826
-				}
1827
-			}
1828
-		}
1829
-
1830
-		/**
1831
-		 * Replace block attributes placeholders with the proper naming.
1832
-		 *
1833
-		 * @param $string
1834
-		 *
1835
-		 * @return mixed
1836
-		 */
1837
-		public function block_props_replace( $string, $no_wrap = false ) {
1838
-
1839
-			if ( $no_wrap ) {
1840
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1841
-			} else {
1842
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1843
-			}
1844
-
1845
-			return $string;
1846
-		}
1847
-
1848
-		/**
1849
-		 * Outputs the content of the widget
1850
-		 *
1851
-		 * @param array $args
1852
-		 * @param array $instance
1853
-		 */
1854
-		public function widget( $args, $instance ) {
1855
-
1856
-			// get the filtered values
1857
-			$argument_values = $this->argument_values( $instance );
1858
-			$argument_values = $this->string_to_bool( $argument_values );
1859
-			$output          = $this->output( $argument_values, $args );
1860
-
1861
-			if ( $output ) {
1862
-				// Before widget
1863
-				$before_widget = $args['before_widget'];
1864
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1865
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1866
-
1867
-				// After widget
1868
-				$after_widget = $args['after_widget'];
1869
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1870
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1871
-
1872
-				echo $before_widget;
1873
-				// elementor strips the widget wrapping div so we check for and add it back if needed
1874
-				if ( $this->is_elementor_widget_output() ) {
1875
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
1876
-				}
1877
-				echo $this->output_title( $args, $instance );
1878
-				echo $output;
1879
-				if ( $this->is_elementor_widget_output() ) {
1880
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
1881
-				}
1882
-				echo $after_widget;
1883
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
1884
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1885
-				echo $output;
1886
-			}
1887
-		}
1888
-
1889
-		/**
1890
-		 * Tests if the current output is inside a elementor container.
1891
-		 *
1892
-		 * @since 1.0.4
1893
-		 * @return bool
1894
-		 */
1895
-		public function is_elementor_widget_output() {
1896
-			$result = false;
1897
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
1898
-				$result = true;
1899
-			}
1900
-
1901
-			return $result;
1902
-		}
1903
-
1904
-		/**
1905
-		 * Tests if the current output is inside a elementor preview.
1906
-		 *
1907
-		 * @since 1.0.4
1908
-		 * @return bool
1909
-		 */
1910
-		public function is_elementor_preview() {
1911
-			$result = false;
1912
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
1913
-				$result = true;
1914
-			}
1915
-
1916
-			return $result;
1917
-		}
1918
-
1919
-		/**
1920
-		 * Tests if the current output is inside a Divi preview.
1921
-		 *
1922
-		 * @since 1.0.6
1923
-		 * @return bool
1924
-		 */
1925
-		public function is_divi_preview() {
1926
-			$result = false;
1927
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
1928
-				$result = true;
1929
-			}
1930
-
1931
-			return $result;
1932
-		}
1933
-
1934
-		/**
1935
-		 * Tests if the current output is inside a Beaver builder preview.
1936
-		 *
1937
-		 * @since 1.0.6
1938
-		 * @return bool
1939
-		 */
1940
-		public function is_beaver_preview() {
1941
-			$result = false;
1942
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
1943
-				$result = true;
1944
-			}
1945
-
1946
-			return $result;
1947
-		}
1948
-
1949
-		/**
1950
-		 * Tests if the current output is inside a siteorigin builder preview.
1951
-		 *
1952
-		 * @since 1.0.6
1953
-		 * @return bool
1954
-		 */
1955
-		public function is_siteorigin_preview() {
1956
-			$result = false;
1957
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
1958
-				$result = true;
1959
-			}
1960
-
1961
-			return $result;
1962
-		}
1963
-
1964
-		/**
1965
-		 * Tests if the current output is inside a cornerstone builder preview.
1966
-		 *
1967
-		 * @since 1.0.8
1968
-		 * @return bool
1969
-		 */
1970
-		public function is_cornerstone_preview() {
1971
-			$result = false;
1972
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
1973
-				$result = true;
1974
-			}
1975
-
1976
-			return $result;
1977
-		}
1978
-
1979
-		/**
1980
-		 * General function to check if we are in a preview situation.
1981
-		 *
1982
-		 * @since 1.0.6
1983
-		 * @return bool
1984
-		 */
1985
-		public function is_preview() {
1986
-			$preview = false;
1987
-			if ( $this->is_divi_preview() ) {
1988
-				$preview = true;
1989
-			} elseif ( $this->is_elementor_preview() ) {
1990
-				$preview = true;
1991
-			} elseif ( $this->is_beaver_preview() ) {
1992
-				$preview = true;
1993
-			} elseif ( $this->is_siteorigin_preview() ) {
1994
-				$preview = true;
1995
-			} elseif ( $this->is_cornerstone_preview() ) {
1996
-				$preview = true;
1997
-			}
1998
-
1999
-			return $preview;
2000
-		}
2001
-
2002
-		/**
2003
-		 * Output the super title.
2004
-		 *
2005
-		 * @param $args
2006
-		 * @param array $instance
2007
-		 *
2008
-		 * @return string
2009
-		 */
2010
-		public function output_title( $args, $instance = array() ) {
2011
-			$output = '';
2012
-			if ( ! empty( $instance['title'] ) ) {
2013
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2014
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2015
-				$output = $args['before_title'] . $title . $args['after_title'];
2016
-			}
2017
-
2018
-			return $output;
2019
-		}
2020
-
2021
-		/**
2022
-		 * Outputs the options form inputs for the widget.
2023
-		 *
2024
-		 * @param array $instance The widget options.
2025
-		 */
2026
-		public function form( $instance ) {
2027
-
2028
-			// set widget instance
2029
-			$this->instance = $instance;
2030
-
2031
-			// set it as a SD widget
2032
-			echo $this->widget_advanced_toggle();
2033
-
2034
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2035
-			$arguments = $this->get_arguments();
2036
-
2037
-			if ( is_array( $arguments ) ) {
2038
-				foreach ( $arguments as $key => $args ) {
2039
-					$this->widget_inputs( $args, $instance );
2040
-				}
2041
-			}
2042
-		}
2043
-
2044
-		/**
2045
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
2046
-		 *
2047
-		 * @return string
2048
-		 */
2049
-		public function widget_advanced_toggle() {
2050
-
2051
-			$output = '';
2052
-			if ( $this->block_show_advanced() ) {
2053
-				$val = 1;
2054
-			} else {
2055
-				$val = 0;
2056
-			}
2057
-
2058
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
2059
-
2060
-			return $output;
2061
-		}
2062
-
2063
-		/**
2064
-		 * Convert require element.
2065
-		 *
2066
-		 * @since 1.0.0
2067
-		 *
2068
-		 * @param string $input Input element.
2069
-		 *
2070
-		 * @return string $output
2071
-		 */
2072
-		public function convert_element_require( $input ) {
2073
-
2074
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2075
-
2076
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2077
-				"jQuery(form).find('[data-argument=\"",
2078
-				"\"]').find('input,select').val()"
2079
-			), $input ) );
2080
-
2081
-			return $output;
2082
-		}
2083
-
2084
-		/**
2085
-		 * Builds the inputs for the widget options.
2086
-		 *
2087
-		 * @param $args
2088
-		 * @param $instance
2089
-		 */
2090
-		public function widget_inputs( $args, $instance ) {
2091
-
2092
-			$class             = "";
2093
-			$element_require   = "";
2094
-			$custom_attributes = "";
2095
-
2096
-			// get value
2097
-			if ( isset( $instance[ $args['name'] ] ) ) {
2098
-				$value = $instance[ $args['name'] ];
2099
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2100
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2101
-			} else {
2102
-				$value = '';
2103
-			}
2104
-
2105
-			// get placeholder
2106
-			if ( ! empty( $args['placeholder'] ) ) {
2107
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2108
-			} else {
2109
-				$placeholder = '';
2110
-			}
2111
-
2112
-			// get if advanced
2113
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2114
-				$class .= " sd-advanced-setting ";
2115
-			}
2116
-
2117
-			// element_require
2118
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2119
-				$element_require = $args['element_require'];
2120
-			}
2121
-
2122
-			// custom_attributes
2123
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2124
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2125
-			}
2126
-
2127
-			// before wrapper
2128
-			?>
1703
+            return str_replace( array(
1704
+                '<script>',
1705
+                '</script>'
1706
+            ), '', $output );
1707
+        }
1708
+
1709
+        /**
1710
+         * Convert an array of attributes to block string.
1711
+         *
1712
+         * @todo there is prob a faster way to do this, also we could add some validation here.
1713
+         *
1714
+         * @param $custom_attributes
1715
+         *
1716
+         * @return string
1717
+         */
1718
+        public function array_to_attributes( $custom_attributes, $html = false ) {
1719
+            $attributes = '';
1720
+            if ( ! empty( $custom_attributes ) ) {
1721
+
1722
+                if ( $html ) {
1723
+                    foreach ( $custom_attributes as $key => $val ) {
1724
+                        $attributes .= " $key='$val' ";
1725
+                    }
1726
+                } else {
1727
+                    foreach ( $custom_attributes as $key => $val ) {
1728
+                        $attributes .= "'$key': '$val',";
1729
+                    }
1730
+                }
1731
+            }
1732
+
1733
+            return $attributes;
1734
+        }
1735
+
1736
+        /**
1737
+         * A self looping function to create the output for JS block elements.
1738
+         *
1739
+         * This is what is output in the WP Editor visual view.
1740
+         *
1741
+         * @param $args
1742
+         */
1743
+        public function block_element( $args ) {
1744
+
1745
+
1746
+            if ( ! empty( $args ) ) {
1747
+                foreach ( $args as $element => $new_args ) {
1748
+
1749
+                    if ( is_array( $new_args ) ) { // its an element
1750
+
1751
+
1752
+                        if ( isset( $new_args['element'] ) ) {
1753
+
1754
+                            if ( isset( $new_args['element_require'] ) ) {
1755
+                                echo str_replace( array(
1756
+                                        "'+",
1757
+                                        "+'"
1758
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1759
+                                unset( $new_args['element_require'] );
1760
+                            }
1761
+
1762
+                            echo "\n el( '" . $new_args['element'] . "', {";
1763
+
1764
+                            // get the attributes
1765
+                            foreach ( $new_args as $new_key => $new_value ) {
1766
+
1767
+
1768
+                                if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1769
+                                    // do nothing
1770
+                                } else {
1771
+                                    echo $this->block_element( array( $new_key => $new_value ) );
1772
+                                }
1773
+                            }
1774
+
1775
+                            echo "},";// end attributes
1776
+
1777
+                            // get the content
1778
+                            $first_item = 0;
1779
+                            foreach ( $new_args as $new_key => $new_value ) {
1780
+                                if ( $new_key === 'content' || is_array( $new_value ) ) {
1781
+
1782
+                                    if ( $new_key === 'content' ) {
1783
+                                        echo "'" . $this->block_props_replace( $new_value ) . "'";
1784
+                                    }
1785
+
1786
+                                    if ( is_array( $new_value ) ) {
1787
+
1788
+                                        if ( isset( $new_value['element_require'] ) ) {
1789
+                                            echo str_replace( array(
1790
+                                                    "'+",
1791
+                                                    "+'"
1792
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1793
+                                            unset( $new_value['element_require'] );
1794
+                                        }
1795
+
1796
+                                        if ( isset( $new_value['element_repeat'] ) ) {
1797
+                                            $x = 1;
1798
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
1799
+                                                $this->block_element( array( '' => $new_value ) );
1800
+                                                $x ++;
1801
+                                            }
1802
+                                        } else {
1803
+                                            $this->block_element( array( '' => $new_value ) );
1804
+                                        }
1805
+                                    }
1806
+                                    $first_item ++;
1807
+                                }
1808
+                            }
1809
+
1810
+                            echo ")";// end content
1811
+
1812
+                            echo ", \n";
1813
+
1814
+                        }
1815
+                    } else {
1816
+
1817
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
1818
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1819
+                        } elseif ( $element == 'style' ) {
1820
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1821
+                        } else {
1822
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1823
+                        }
1824
+
1825
+                    }
1826
+                }
1827
+            }
1828
+        }
1829
+
1830
+        /**
1831
+         * Replace block attributes placeholders with the proper naming.
1832
+         *
1833
+         * @param $string
1834
+         *
1835
+         * @return mixed
1836
+         */
1837
+        public function block_props_replace( $string, $no_wrap = false ) {
1838
+
1839
+            if ( $no_wrap ) {
1840
+                $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1841
+            } else {
1842
+                $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1843
+            }
1844
+
1845
+            return $string;
1846
+        }
1847
+
1848
+        /**
1849
+         * Outputs the content of the widget
1850
+         *
1851
+         * @param array $args
1852
+         * @param array $instance
1853
+         */
1854
+        public function widget( $args, $instance ) {
1855
+
1856
+            // get the filtered values
1857
+            $argument_values = $this->argument_values( $instance );
1858
+            $argument_values = $this->string_to_bool( $argument_values );
1859
+            $output          = $this->output( $argument_values, $args );
1860
+
1861
+            if ( $output ) {
1862
+                // Before widget
1863
+                $before_widget = $args['before_widget'];
1864
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1865
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1866
+
1867
+                // After widget
1868
+                $after_widget = $args['after_widget'];
1869
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1870
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1871
+
1872
+                echo $before_widget;
1873
+                // elementor strips the widget wrapping div so we check for and add it back if needed
1874
+                if ( $this->is_elementor_widget_output() ) {
1875
+                    echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
1876
+                }
1877
+                echo $this->output_title( $args, $instance );
1878
+                echo $output;
1879
+                if ( $this->is_elementor_widget_output() ) {
1880
+                    echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
1881
+                }
1882
+                echo $after_widget;
1883
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
1884
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1885
+                echo $output;
1886
+            }
1887
+        }
1888
+
1889
+        /**
1890
+         * Tests if the current output is inside a elementor container.
1891
+         *
1892
+         * @since 1.0.4
1893
+         * @return bool
1894
+         */
1895
+        public function is_elementor_widget_output() {
1896
+            $result = false;
1897
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
1898
+                $result = true;
1899
+            }
1900
+
1901
+            return $result;
1902
+        }
1903
+
1904
+        /**
1905
+         * Tests if the current output is inside a elementor preview.
1906
+         *
1907
+         * @since 1.0.4
1908
+         * @return bool
1909
+         */
1910
+        public function is_elementor_preview() {
1911
+            $result = false;
1912
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
1913
+                $result = true;
1914
+            }
1915
+
1916
+            return $result;
1917
+        }
1918
+
1919
+        /**
1920
+         * Tests if the current output is inside a Divi preview.
1921
+         *
1922
+         * @since 1.0.6
1923
+         * @return bool
1924
+         */
1925
+        public function is_divi_preview() {
1926
+            $result = false;
1927
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
1928
+                $result = true;
1929
+            }
1930
+
1931
+            return $result;
1932
+        }
1933
+
1934
+        /**
1935
+         * Tests if the current output is inside a Beaver builder preview.
1936
+         *
1937
+         * @since 1.0.6
1938
+         * @return bool
1939
+         */
1940
+        public function is_beaver_preview() {
1941
+            $result = false;
1942
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
1943
+                $result = true;
1944
+            }
1945
+
1946
+            return $result;
1947
+        }
1948
+
1949
+        /**
1950
+         * Tests if the current output is inside a siteorigin builder preview.
1951
+         *
1952
+         * @since 1.0.6
1953
+         * @return bool
1954
+         */
1955
+        public function is_siteorigin_preview() {
1956
+            $result = false;
1957
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
1958
+                $result = true;
1959
+            }
1960
+
1961
+            return $result;
1962
+        }
1963
+
1964
+        /**
1965
+         * Tests if the current output is inside a cornerstone builder preview.
1966
+         *
1967
+         * @since 1.0.8
1968
+         * @return bool
1969
+         */
1970
+        public function is_cornerstone_preview() {
1971
+            $result = false;
1972
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
1973
+                $result = true;
1974
+            }
1975
+
1976
+            return $result;
1977
+        }
1978
+
1979
+        /**
1980
+         * General function to check if we are in a preview situation.
1981
+         *
1982
+         * @since 1.0.6
1983
+         * @return bool
1984
+         */
1985
+        public function is_preview() {
1986
+            $preview = false;
1987
+            if ( $this->is_divi_preview() ) {
1988
+                $preview = true;
1989
+            } elseif ( $this->is_elementor_preview() ) {
1990
+                $preview = true;
1991
+            } elseif ( $this->is_beaver_preview() ) {
1992
+                $preview = true;
1993
+            } elseif ( $this->is_siteorigin_preview() ) {
1994
+                $preview = true;
1995
+            } elseif ( $this->is_cornerstone_preview() ) {
1996
+                $preview = true;
1997
+            }
1998
+
1999
+            return $preview;
2000
+        }
2001
+
2002
+        /**
2003
+         * Output the super title.
2004
+         *
2005
+         * @param $args
2006
+         * @param array $instance
2007
+         *
2008
+         * @return string
2009
+         */
2010
+        public function output_title( $args, $instance = array() ) {
2011
+            $output = '';
2012
+            if ( ! empty( $instance['title'] ) ) {
2013
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2014
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2015
+                $output = $args['before_title'] . $title . $args['after_title'];
2016
+            }
2017
+
2018
+            return $output;
2019
+        }
2020
+
2021
+        /**
2022
+         * Outputs the options form inputs for the widget.
2023
+         *
2024
+         * @param array $instance The widget options.
2025
+         */
2026
+        public function form( $instance ) {
2027
+
2028
+            // set widget instance
2029
+            $this->instance = $instance;
2030
+
2031
+            // set it as a SD widget
2032
+            echo $this->widget_advanced_toggle();
2033
+
2034
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2035
+            $arguments = $this->get_arguments();
2036
+
2037
+            if ( is_array( $arguments ) ) {
2038
+                foreach ( $arguments as $key => $args ) {
2039
+                    $this->widget_inputs( $args, $instance );
2040
+                }
2041
+            }
2042
+        }
2043
+
2044
+        /**
2045
+         * Get the hidden input that when added makes the advanced button show on widget settings.
2046
+         *
2047
+         * @return string
2048
+         */
2049
+        public function widget_advanced_toggle() {
2050
+
2051
+            $output = '';
2052
+            if ( $this->block_show_advanced() ) {
2053
+                $val = 1;
2054
+            } else {
2055
+                $val = 0;
2056
+            }
2057
+
2058
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
2059
+
2060
+            return $output;
2061
+        }
2062
+
2063
+        /**
2064
+         * Convert require element.
2065
+         *
2066
+         * @since 1.0.0
2067
+         *
2068
+         * @param string $input Input element.
2069
+         *
2070
+         * @return string $output
2071
+         */
2072
+        public function convert_element_require( $input ) {
2073
+
2074
+            $input = str_replace( "'", '"', $input );// we only want double quotes
2075
+
2076
+            $output = esc_attr( str_replace( array( "[%", "%]" ), array(
2077
+                "jQuery(form).find('[data-argument=\"",
2078
+                "\"]').find('input,select').val()"
2079
+            ), $input ) );
2080
+
2081
+            return $output;
2082
+        }
2083
+
2084
+        /**
2085
+         * Builds the inputs for the widget options.
2086
+         *
2087
+         * @param $args
2088
+         * @param $instance
2089
+         */
2090
+        public function widget_inputs( $args, $instance ) {
2091
+
2092
+            $class             = "";
2093
+            $element_require   = "";
2094
+            $custom_attributes = "";
2095
+
2096
+            // get value
2097
+            if ( isset( $instance[ $args['name'] ] ) ) {
2098
+                $value = $instance[ $args['name'] ];
2099
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2100
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2101
+            } else {
2102
+                $value = '';
2103
+            }
2104
+
2105
+            // get placeholder
2106
+            if ( ! empty( $args['placeholder'] ) ) {
2107
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2108
+            } else {
2109
+                $placeholder = '';
2110
+            }
2111
+
2112
+            // get if advanced
2113
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2114
+                $class .= " sd-advanced-setting ";
2115
+            }
2116
+
2117
+            // element_require
2118
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2119
+                $element_require = $args['element_require'];
2120
+            }
2121
+
2122
+            // custom_attributes
2123
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2124
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2125
+            }
2126
+
2127
+            // before wrapper
2128
+            ?>
2129 2129
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2130 2130
 			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2131 2131
 			   data-element_require='<?php if ( $element_require ) {
2132
-				   echo $this->convert_element_require( $element_require );
2133
-			   } ?>'
2132
+                    echo $this->convert_element_require( $element_require );
2133
+                } ?>'
2134 2134
 			>
2135 2135
 				<?php
2136 2136
 
2137
-				switch ( $args['type'] ) {
2138
-					//array('text','password','number','email','tel','url','color')
2139
-					case "text":
2140
-					case "password":
2141
-					case "number":
2142
-					case "email":
2143
-					case "tel":
2144
-					case "url":
2145
-					case "color":
2146
-						?>
2137
+                switch ( $args['type'] ) {
2138
+                    //array('text','password','number','email','tel','url','color')
2139
+                    case "text":
2140
+                    case "password":
2141
+                    case "number":
2142
+                    case "email":
2143
+                    case "tel":
2144
+                    case "url":
2145
+                    case "color":
2146
+                        ?>
2147 2147
 						<label
2148 2148
 							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>
2149 2149
 						<input <?php echo $placeholder; ?> class="widefat"
@@ -2154,47 +2154,47 @@  discard block
 block discarded – undo
2154 2154
 							                               value="<?php echo esc_attr( $value ); ?>">
2155 2155
 						<?php
2156 2156
 
2157
-						break;
2158
-					case "select":
2159
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2160
-						if ( $multiple ) {
2161
-							if ( empty( $value ) ) {
2162
-								$value = array();
2163
-							}
2164
-						}
2165
-						?>
2157
+                        break;
2158
+                    case "select":
2159
+                        $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2160
+                        if ( $multiple ) {
2161
+                            if ( empty( $value ) ) {
2162
+                                $value = array();
2163
+                            }
2164
+                        }
2165
+                        ?>
2166 2166
 						<label
2167 2167
 							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>
2168 2168
 						<select <?php echo $placeholder; ?> class="widefat"
2169 2169
 							<?php echo $custom_attributes; ?>
2170 2170
 							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2171 2171
 							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2172
-							                                if ( $multiple ) {
2173
-								                                echo "[]";
2174
-							                                } ?>"
2172
+                                                            if ( $multiple ) {
2173
+                                                                echo "[]";
2174
+                                                            } ?>"
2175 2175
 							<?php if ( $multiple ) {
2176
-								echo "multiple";
2177
-							} //@todo not implemented yet due to gutenberg not supporting it
2178
-							?>
2176
+                                echo "multiple";
2177
+                            } //@todo not implemented yet due to gutenberg not supporting it
2178
+                            ?>
2179 2179
 						>
2180 2180
 							<?php
2181 2181
 
2182
-							if ( ! empty( $args['options'] ) ) {
2183
-								foreach ( $args['options'] as $val => $label ) {
2184
-									if ( $multiple ) {
2185
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2186
-									} else {
2187
-										$selected = selected( $value, $val, false );
2188
-									}
2189
-									echo "<option value='$val' " . $selected . ">$label</option>";
2190
-								}
2191
-							}
2192
-							?>
2182
+                            if ( ! empty( $args['options'] ) ) {
2183
+                                foreach ( $args['options'] as $val => $label ) {
2184
+                                    if ( $multiple ) {
2185
+                                        $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2186
+                                    } else {
2187
+                                        $selected = selected( $value, $val, false );
2188
+                                    }
2189
+                                    echo "<option value='$val' " . $selected . ">$label</option>";
2190
+                                }
2191
+                            }
2192
+                            ?>
2193 2193
 						</select>
2194 2194
 						<?php
2195
-						break;
2196
-					case "checkbox":
2197
-						?>
2195
+                        break;
2196
+                    case "checkbox":
2197
+                        ?>
2198 2198
 						<input <?php echo $placeholder; ?>
2199 2199
 							<?php checked( 1, $value, true ) ?>
2200 2200
 							<?php echo $custom_attributes; ?>
@@ -2204,136 +2204,136 @@  discard block
 block discarded – undo
2204 2204
 						<label
2205 2205
 							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>
2206 2206
 						<?php
2207
-						break;
2208
-					case "hidden":
2209
-						?>
2207
+                        break;
2208
+                    case "hidden":
2209
+                        ?>
2210 2210
 						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2211 2211
 						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2212 2212
 						       value="<?php echo esc_attr( $value ); ?>">
2213 2213
 						<?php
2214
-						break;
2215
-					default:
2216
-						echo "No input type found!"; // @todo we need to add more input types.
2217
-				}
2214
+                        break;
2215
+                    default:
2216
+                        echo "No input type found!"; // @todo we need to add more input types.
2217
+                }
2218 2218
 
2219
-				// after wrapper
2220
-				?>
2219
+                // after wrapper
2220
+                ?>
2221 2221
 			</p>
2222 2222
 			<?php
2223 2223
 
2224
-		}
2225
-
2226
-		/**
2227
-		 * Get the widget input description html.
2228
-		 *
2229
-		 * @param $args
2230
-		 *
2231
-		 * @return string
2232
-		 * @todo, need to make its own tooltip script
2233
-		 */
2234
-		public function widget_field_desc( $args ) {
2235
-
2236
-			$description = '';
2237
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2238
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2239
-					$description = $this->desc_tip( $args['desc'] );
2240
-				} else {
2241
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2242
-				}
2243
-			}
2244
-
2245
-			return $description;
2246
-		}
2247
-
2248
-		/**
2249
-		 * Get the tool tip html.
2250
-		 *
2251
-		 * @param $tip
2252
-		 * @param bool $allow_html
2253
-		 *
2254
-		 * @return string
2255
-		 */
2256
-		function desc_tip( $tip, $allow_html = false ) {
2257
-			if ( $allow_html ) {
2258
-				$tip = $this->sanitize_tooltip( $tip );
2259
-			} else {
2260
-				$tip = esc_attr( $tip );
2261
-			}
2262
-
2263
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
2264
-		}
2265
-
2266
-		/**
2267
-		 * Sanitize a string destined to be a tooltip.
2268
-		 *
2269
-		 * @param string $var
2270
-		 *
2271
-		 * @return string
2272
-		 */
2273
-		public function sanitize_tooltip( $var ) {
2274
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2275
-				'br'     => array(),
2276
-				'em'     => array(),
2277
-				'strong' => array(),
2278
-				'small'  => array(),
2279
-				'span'   => array(),
2280
-				'ul'     => array(),
2281
-				'li'     => array(),
2282
-				'ol'     => array(),
2283
-				'p'      => array(),
2284
-			) ) );
2285
-		}
2286
-
2287
-		/**
2288
-		 * Processing widget options on save
2289
-		 *
2290
-		 * @param array $new_instance The new options
2291
-		 * @param array $old_instance The previous options
2292
-		 *
2293
-		 * @return array
2294
-		 * @todo we should add some sanitation here.
2295
-		 */
2296
-		public function update( $new_instance, $old_instance ) {
2297
-
2298
-			//save the widget
2299
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2300
-
2301
-			// set widget instance
2302
-			$this->instance = $instance;
2303
-
2304
-			if ( empty( $this->arguments ) ) {
2305
-				$this->get_arguments();
2306
-			}
2307
-
2308
-			// check for checkboxes
2309
-			if ( ! empty( $this->arguments ) ) {
2310
-				foreach ( $this->arguments as $argument ) {
2311
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2312
-						$instance[ $argument['name'] ] = '0';
2313
-					}
2314
-				}
2315
-			}
2316
-
2317
-			return $instance;
2318
-		}
2319
-
2320
-		/**
2321
-		 * Checks if the current call is a ajax call to get the block content.
2322
-		 *
2323
-		 * This can be used in your widget to return different content as the block content.
2324
-		 *
2325
-		 * @since 1.0.3
2326
-		 * @return bool
2327
-		 */
2328
-		public function is_block_content_call() {
2329
-			$result = false;
2330
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2331
-				$result = true;
2332
-			}
2333
-
2334
-			return $result;
2335
-		}
2336
-
2337
-	}
2224
+        }
2225
+
2226
+        /**
2227
+         * Get the widget input description html.
2228
+         *
2229
+         * @param $args
2230
+         *
2231
+         * @return string
2232
+         * @todo, need to make its own tooltip script
2233
+         */
2234
+        public function widget_field_desc( $args ) {
2235
+
2236
+            $description = '';
2237
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
2238
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2239
+                    $description = $this->desc_tip( $args['desc'] );
2240
+                } else {
2241
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2242
+                }
2243
+            }
2244
+
2245
+            return $description;
2246
+        }
2247
+
2248
+        /**
2249
+         * Get the tool tip html.
2250
+         *
2251
+         * @param $tip
2252
+         * @param bool $allow_html
2253
+         *
2254
+         * @return string
2255
+         */
2256
+        function desc_tip( $tip, $allow_html = false ) {
2257
+            if ( $allow_html ) {
2258
+                $tip = $this->sanitize_tooltip( $tip );
2259
+            } else {
2260
+                $tip = esc_attr( $tip );
2261
+            }
2262
+
2263
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
2264
+        }
2265
+
2266
+        /**
2267
+         * Sanitize a string destined to be a tooltip.
2268
+         *
2269
+         * @param string $var
2270
+         *
2271
+         * @return string
2272
+         */
2273
+        public function sanitize_tooltip( $var ) {
2274
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2275
+                'br'     => array(),
2276
+                'em'     => array(),
2277
+                'strong' => array(),
2278
+                'small'  => array(),
2279
+                'span'   => array(),
2280
+                'ul'     => array(),
2281
+                'li'     => array(),
2282
+                'ol'     => array(),
2283
+                'p'      => array(),
2284
+            ) ) );
2285
+        }
2286
+
2287
+        /**
2288
+         * Processing widget options on save
2289
+         *
2290
+         * @param array $new_instance The new options
2291
+         * @param array $old_instance The previous options
2292
+         *
2293
+         * @return array
2294
+         * @todo we should add some sanitation here.
2295
+         */
2296
+        public function update( $new_instance, $old_instance ) {
2297
+
2298
+            //save the widget
2299
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
2300
+
2301
+            // set widget instance
2302
+            $this->instance = $instance;
2303
+
2304
+            if ( empty( $this->arguments ) ) {
2305
+                $this->get_arguments();
2306
+            }
2307
+
2308
+            // check for checkboxes
2309
+            if ( ! empty( $this->arguments ) ) {
2310
+                foreach ( $this->arguments as $argument ) {
2311
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2312
+                        $instance[ $argument['name'] ] = '0';
2313
+                    }
2314
+                }
2315
+            }
2316
+
2317
+            return $instance;
2318
+        }
2319
+
2320
+        /**
2321
+         * Checks if the current call is a ajax call to get the block content.
2322
+         *
2323
+         * This can be used in your widget to return different content as the block content.
2324
+         *
2325
+         * @since 1.0.3
2326
+         * @return bool
2327
+         */
2328
+        public function is_block_content_call() {
2329
+            $result = false;
2330
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2331
+                $result = true;
2332
+            }
2333
+
2334
+            return $result;
2335
+        }
2336
+
2337
+    }
2338 2338
 
2339 2339
 }
2340 2340
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +364 added lines, -364 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,43 +65,43 @@  discard block
 block discarded – undo
65 65
 				$this->register_shortcode();
66 66
 
67 67
 				// register block
68
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
68
+				add_action('admin_enqueue_scripts', array($this, 'register_block'));
69 69
 			}
70 70
 
71 71
 			// add the CSS and JS we need ONCE
72 72
 			global $sd_widget_scripts;
73 73
 
74
-			if ( ! $sd_widget_scripts ) {
75
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
76
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
77
-				wp_add_inline_style( 'widgets', $this->widget_css() );
74
+			if (!$sd_widget_scripts) {
75
+				wp_add_inline_script('admin-widgets', $this->widget_js());
76
+				wp_add_inline_script('customize-controls', $this->widget_js());
77
+				wp_add_inline_style('widgets', $this->widget_css());
78 78
 
79 79
 				$sd_widget_scripts = true;
80 80
 
81 81
 				// add shortcode insert button once
82
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
83
-				if ( $this->is_preview() ) {
84
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
82
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
83
+				if ($this->is_preview()) {
84
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
85 85
 					// this makes the insert button work for elementor
86
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
86
+					add_action('elementor/editor/after_enqueue_scripts', array(
87 87
 						$this,
88 88
 						'shortcode_insert_button_script'
89
-					) ); // for elementor
89
+					)); // for elementor
90 90
 				}
91 91
 				// this makes the insert button work for cornerstone
92
-				add_action( 'cornerstone_load_builder', array(
92
+				add_action('cornerstone_load_builder', array(
93 93
 					$this,
94 94
 					'shortcode_insert_button_script'
95
-				) ); // for cornerstone builder (this is the preview)
95
+				)); // for cornerstone builder (this is the preview)
96 96
 
97
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
98
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
97
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
98
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
99 99
 
100 100
 				// add generator text to admin head
101
-				add_action( 'admin_head', array( $this, 'generator' ) );
101
+				add_action('admin_head', array($this, 'generator'));
102 102
 			}
103 103
 
104
-			do_action( 'wp_super_duper_widget_init', $options, $this );
104
+			do_action('wp_super_duper_widget_init', $options, $this);
105 105
 		}
106 106
 
107 107
 		/**
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 		 *
112 112
 		 * @return string
113 113
 		 */
114
-		public static function get_picker( $editor_id = '' ) {
114
+		public static function get_picker($editor_id = '') {
115 115
 
116 116
 			ob_start();
117
-			if ( isset( $_POST['editor_id'] ) ) {
118
-				$editor_id = esc_attr( $_POST['editor_id'] );
119
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
117
+			if (isset($_POST['editor_id'])) {
118
+				$editor_id = esc_attr($_POST['editor_id']);
119
+			} elseif (isset($_REQUEST['et_fb'])) {
120 120
 				$editor_id = 'main_content_content_vb_tiny_mce';
121 121
 			}
122 122
 
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 
126 126
 			<div class="sd-shortcode-left-wrap">
127 127
 				<?php
128
-				asort( $sd_widgets );
129
-				if ( ! empty( $sd_widgets ) ) {
128
+				asort($sd_widgets);
129
+				if (!empty($sd_widgets)) {
130 130
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
131
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
132
-					foreach ( $sd_widgets as $shortcode => $class ) {
133
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
131
+					echo "<option>" . __('Select shortcode') . "</option>";
132
+					foreach ($sd_widgets as $shortcode => $class) {
133
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
134 134
 					}
135 135
 					echo "</select>";
136 136
 
@@ -143,37 +143,37 @@  discard block
 block discarded – undo
143 143
 			<div class="sd-shortcode-right-wrap">
144 144
 				<textarea id='sd-shortcode-output' disabled></textarea>
145 145
 				<div id='sd-shortcode-output-actions'>
146
-					<?php if ( $editor_id != '' ) { ?>
146
+					<?php if ($editor_id != '') { ?>
147 147
 						<button class="button sd-insert-shortcode-button"
148
-						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
148
+						        onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
149 149
 							        echo "'" . $editor_id . "'";
150
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
150
+						        } ?>)"><?php _e('Insert shortcode'); ?></button>
151 151
 					<?php } ?>
152 152
 					<button class="button"
153
-					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
153
+					        onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
154 154
 				</div>
155 155
 			</div>
156 156
 			<?php
157 157
 
158 158
 			$html = ob_get_clean();
159 159
 
160
-			if ( wp_doing_ajax() ) {
160
+			if (wp_doing_ajax()) {
161 161
 				echo $html;
162 162
 				$should_die = true;
163 163
 
164 164
 				// some builder get the editor via ajax so we should not die on those ocasions
165 165
 				$dont_die = array(
166
-					'parent_tag',// WP Bakery
166
+					'parent_tag', // WP Bakery
167 167
 					'avia_request' // enfold
168 168
 				);
169 169
 
170
-				foreach ( $dont_die as $request ) {
171
-					if ( isset( $_REQUEST[ $request ] ) ) {
170
+				foreach ($dont_die as $request) {
171
+					if (isset($_REQUEST[$request])) {
172 172
 						$should_die = false;
173 173
 					}
174 174
 				}
175 175
 
176
-				if ( $should_die ) {
176
+				if ($should_die) {
177 177
 					wp_die();
178 178
 				}
179 179
 
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 		public static function get_widget_settings() {
201 201
 			global $sd_widgets;
202 202
 
203
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
204
-			if ( ! $shortcode ) {
203
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
204
+			if (!$shortcode) {
205 205
 				wp_die();
206 206
 			}
207
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
208
-			if ( ! $widget_args ) {
207
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
208
+			if (!$widget_args) {
209 209
 				wp_die();
210 210
 			}
211
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
212
-			if ( ! $class_name ) {
211
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
212
+			if (!$class_name) {
213 213
 				wp_die();
214 214
 			}
215 215
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$widget = new $class_name;
218 218
 
219 219
 			ob_start();
220
-			$widget->form( array() );
220
+			$widget->form(array());
221 221
 			$form = ob_get_clean();
222 222
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
223 223
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
236 236
 		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
237 237
 		 */
238
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
238
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
239 239
 			global $sd_widgets, $shortcode_insert_button_once;
240
-			if ( $shortcode_insert_button_once ) {
240
+			if ($shortcode_insert_button_once) {
241 241
 				return;
242 242
 			}
243 243
 			add_thickbox();
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
 			 * Cornerstone makes us play dirty tricks :/
248 248
 			 * 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.
249 249
 			 */
250
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
250
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
251 251
 				echo '<span id="insert-media-button">';
252 252
 			}
253 253
 
254
-			echo self::shortcode_button( 'this', 'true' );
254
+			echo self::shortcode_button('this', 'true');
255 255
 
256 256
 			// see opening note
257
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
257
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
258 258
 				echo '</span>'; // end #insert-media-button
259 259
 			}
260 260
 
261
-			self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
261
+			self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
262 262
 			$shortcode_insert_button_once = true;
263 263
 		}
264 264
 
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 		 *
271 271
 		 * @return mixed
272 272
 		 */
273
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
273
+		public static function shortcode_button($id = '', $search_for_id = '') {
274 274
 			ob_start();
275 275
 			?>
276 276
 			<span class="sd-lable-shortcode-inserter">
277 277
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
278
-				if ( $search_for_id ) {
278
+				if ($search_for_id) {
279 279
 					echo "," . $search_for_id;
280 280
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
281 281
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			$html = ob_get_clean();
292 292
 
293 293
 			// remove line breaks so we can use it in js
294
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
294
+			return preg_replace("/\r|\n/", "", trim($html));
295 295
 		}
296 296
 
297 297
 		/**
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 						jQuery($this).data('sd-widget-enabled', true);
350 350
 					}
351 351
 
352
-					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>';
352
+					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>';
353 353
 					var form = jQuery($this).parents('' + $selector + '');
354 354
 
355 355
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -386,10 +386,10 @@  discard block
 block discarded – undo
386 386
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
387 387
 			 */
388 388
 
389
-			return str_replace( array(
389
+			return str_replace(array(
390 390
 				'<script>',
391 391
 				'</script>'
392
-			), '', $output );
392
+			), '', $output);
393 393
 		}
394 394
 
395 395
 		/**
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		 * @param string $editor_id
401 401
 		 * @param string $insert_shortcode_function
402 402
 		 */
403
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
403
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
404 404
 			?>
405 405
 			<style>
406 406
 				.sd-shortcode-left-wrap {
@@ -520,15 +520,15 @@  discard block
 block discarded – undo
520 520
 				}
521 521
 			</style>
522 522
 			<?php
523
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
523
+			if (class_exists('SiteOrigin_Panels')) {
524 524
 				echo "<script>" . self::siteorigin_js() . "</script>";
525 525
 			}
526 526
 			?>
527 527
 			<script>
528 528
 				<?php
529
-				if(! empty( $insert_shortcode_function )){
529
+				if (!empty($insert_shortcode_function)) {
530 530
 					echo $insert_shortcode_function;
531
-				}else{
531
+				} else {
532 532
 
533 533
 				/**
534 534
 				 * Function for super duper insert shortcode.
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 						if (!$editor_id) {
544 544
 
545 545
 							<?php
546
-							if ( isset( $_REQUEST['et_fb'] ) ) {
546
+							if (isset($_REQUEST['et_fb'])) {
547 547
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
548
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
548
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
549 549
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
550 550
 							} else {
551 551
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -625,11 +625,11 @@  discard block
 block discarded – undo
625 625
 							'shortcode': $short_code,
626 626
 							'attributes': 123,
627 627
 							'post_id': 321,
628
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
628
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
629 629
 						};
630 630
 
631 631
 						if (typeof ajaxurl === 'undefined') {
632
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
632
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
633 633
 						}
634 634
 
635 635
 						jQuery.post(ajaxurl, data, function (response) {
@@ -818,11 +818,11 @@  discard block
 block discarded – undo
818 818
 					var data = {
819 819
 						'action': 'super_duper_get_picker',
820 820
 						'editor_id': $id,
821
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
821
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
822 822
 					};
823 823
 
824 824
 					if (!ajaxurl) {
825
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
825
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
826 826
 					}
827 827
 
828 828
 					jQuery.post(ajaxurl, data, function (response) {
@@ -843,9 +843,9 @@  discard block
 block discarded – undo
843 843
 				 */
844 844
 				function sd_shortcode_button($id) {
845 845
 					if ($id) {
846
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
846
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
847 847
 					} else {
848
-						return '<?php echo self::shortcode_button();?>';
848
+						return '<?php echo self::shortcode_button(); ?>';
849 849
 					}
850 850
 				}
851 851
 
@@ -888,10 +888,10 @@  discard block
 block discarded – undo
888 888
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
889 889
 			 */
890 890
 
891
-			return str_replace( array(
891
+			return str_replace(array(
892 892
 				'<style>',
893 893
 				'</style>'
894
-			), '', $output );
894
+			), '', $output);
895 895
 		}
896 896
 
897 897
 		/**
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 						jQuery($this).data('sd-widget-enabled', true);
962 962
 					}
963 963
 
964
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" 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>';
964
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" 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>';
965 965
 					var form = jQuery($this).parents('' + $selector + '');
966 966
 
967 967
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 					});
1054 1054
 
1055 1055
 				}
1056
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1056
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1057 1057
 			</script>
1058 1058
 			<?php
1059 1059
 			$output = ob_get_clean();
@@ -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
 				'<script>',
1067 1067
 				'</script>'
1068
-			), '', $output );
1068
+			), '', $output);
1069 1069
 		}
1070 1070
 
1071 1071
 
@@ -1076,14 +1076,14 @@  discard block
 block discarded – undo
1076 1076
 		 *
1077 1077
 		 * @return mixed
1078 1078
 		 */
1079
-		private function add_name_from_key( $options, $arguments = false ) {
1080
-			if ( ! empty( $options['arguments'] ) ) {
1081
-				foreach ( $options['arguments'] as $key => $val ) {
1082
-					$options['arguments'][ $key ]['name'] = $key;
1079
+		private function add_name_from_key($options, $arguments = false) {
1080
+			if (!empty($options['arguments'])) {
1081
+				foreach ($options['arguments'] as $key => $val) {
1082
+					$options['arguments'][$key]['name'] = $key;
1083 1083
 				}
1084
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1085
-				foreach ( $options as $key => $val ) {
1086
-					$options[ $key ]['name'] = $key;
1084
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1085
+				foreach ($options as $key => $val) {
1086
+					$options[$key]['name'] = $key;
1087 1087
 				}
1088 1088
 			}
1089 1089
 
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
 		 * @since 1.0.0
1097 1097
 		 */
1098 1098
 		public function register_shortcode() {
1099
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1100
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1099
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1100
+			add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode'));
1101 1101
 		}
1102 1102
 
1103 1103
 		/**
@@ -1107,33 +1107,33 @@  discard block
 block discarded – undo
1107 1107
 		 */
1108 1108
 		public static function render_shortcode() {
1109 1109
 
1110
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1111
-			if ( ! current_user_can( 'manage_options' ) ) {
1110
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1111
+			if (!current_user_can('manage_options')) {
1112 1112
 				wp_die();
1113 1113
 			}
1114 1114
 
1115 1115
 			// we might need the $post value here so lets set it.
1116
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1117
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1118
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1116
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1117
+				$post_obj = get_post(absint($_POST['post_id']));
1118
+				if (!empty($post_obj) && empty($post)) {
1119 1119
 					global $post;
1120 1120
 					$post = $post_obj;
1121 1121
 				}
1122 1122
 			}
1123 1123
 
1124
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1125
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1126
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1124
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1125
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1126
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1127 1127
 				$attributes       = '';
1128
-				if ( ! empty( $attributes_array ) ) {
1129
-					foreach ( $attributes_array as $key => $value ) {
1130
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1128
+				if (!empty($attributes_array)) {
1129
+					foreach ($attributes_array as $key => $value) {
1130
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' ";
1131 1131
 					}
1132 1132
 				}
1133 1133
 
1134 1134
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1135 1135
 
1136
-				echo do_shortcode( $shortcode );
1136
+				echo do_shortcode($shortcode);
1137 1137
 
1138 1138
 			}
1139 1139
 			wp_die();
@@ -1147,37 +1147,37 @@  discard block
 block discarded – undo
1147 1147
 		 *
1148 1148
 		 * @return string
1149 1149
 		 */
1150
-		public function shortcode_output( $args = array(), $content = '' ) {
1151
-			$args = self::argument_values( $args );
1150
+		public function shortcode_output($args = array(), $content = '') {
1151
+			$args = self::argument_values($args);
1152 1152
 
1153 1153
 			// add extra argument so we know its a output to gutenberg
1154 1154
 			//$args
1155
-			$args = $this->string_to_bool( $args );
1155
+			$args = $this->string_to_bool($args);
1156 1156
 
1157 1157
 
1158
-			$calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1158
+			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1159 1159
 
1160
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1161
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1160
+			$calss = apply_filters('wp_super_duper_div_classname', $calss, $args, $this);
1161
+			$calss = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this);
1162 1162
 
1163
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1164
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1163
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1164
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
1165 1165
 
1166 1166
 			$shortcode_args = array();
1167 1167
 			$output         = '';
1168
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1169
-			$main_content   = $this->output( $args, $shortcode_args, $content );
1170
-			if ( $main_content && ! $no_wrap ) {
1168
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1169
+			$main_content   = $this->output($args, $shortcode_args, $content);
1170
+			if ($main_content && !$no_wrap) {
1171 1171
 				// wrap the shortcode in a dive with the same class as the widget
1172 1172
 				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
1173
-				if ( ! empty( $args['title'] ) ) {
1173
+				if (!empty($args['title'])) {
1174 1174
 					// if its a shortcode and there is a title try to grab the title wrappers
1175
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1176
-					if ( empty( $instance ) ) {
1175
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1176
+					if (empty($instance)) {
1177 1177
 						global $wp_registered_sidebars;
1178
-						if ( ! empty( $wp_registered_sidebars ) ) {
1179
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1180
-								if ( ! empty( $sidebar['before_title'] ) ) {
1178
+						if (!empty($wp_registered_sidebars)) {
1179
+							foreach ($wp_registered_sidebars as $sidebar) {
1180
+								if (!empty($sidebar['before_title'])) {
1181 1181
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1182 1182
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1183 1183
 									break;
@@ -1185,17 +1185,17 @@  discard block
 block discarded – undo
1185 1185
 							}
1186 1186
 						}
1187 1187
 					}
1188
-					$output .= $this->output_title( $shortcode_args, $args );
1188
+					$output .= $this->output_title($shortcode_args, $args);
1189 1189
 				}
1190 1190
 				$output .= $main_content;
1191 1191
 				$output .= '</div>';
1192
-			} elseif ( $main_content && $no_wrap ) {
1192
+			} elseif ($main_content && $no_wrap) {
1193 1193
 				$output .= $main_content;
1194 1194
 			}
1195 1195
 
1196 1196
 			// if preview show a placeholder if empty
1197
-			if ( $this->is_preview() && $output == '' ) {
1198
-				$output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1197
+			if ($this->is_preview() && $output == '') {
1198
+				$output = $this->preview_placeholder_text("[{" . $this->base_id . "}]");
1199 1199
 			}
1200 1200
 
1201 1201
 			return $output;
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
 		 *
1209 1209
 		 * @return string
1210 1210
 		 */
1211
-		public function preview_placeholder_text( $name = '' ) {
1212
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1211
+		public function preview_placeholder_text($name = '') {
1212
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>";
1213 1213
 		}
1214 1214
 
1215 1215
 		/**
@@ -1219,13 +1219,13 @@  discard block
 block discarded – undo
1219 1219
 		 *
1220 1220
 		 * @return mixed
1221 1221
 		 */
1222
-		public function string_to_bool( $options ) {
1222
+		public function string_to_bool($options) {
1223 1223
 			// convert bool strings to booleans
1224
-			foreach ( $options as $key => $val ) {
1225
-				if ( $val == 'false' ) {
1226
-					$options[ $key ] = false;
1227
-				} elseif ( $val == 'true' ) {
1228
-					$options[ $key ] = true;
1224
+			foreach ($options as $key => $val) {
1225
+				if ($val == 'false') {
1226
+					$options[$key] = false;
1227
+				} elseif ($val == 'true') {
1228
+					$options[$key] = true;
1229 1229
 				}
1230 1230
 			}
1231 1231
 
@@ -1239,24 +1239,24 @@  discard block
 block discarded – undo
1239 1239
 		 *
1240 1240
 		 * @return array
1241 1241
 		 */
1242
-		public function argument_values( $instance ) {
1242
+		public function argument_values($instance) {
1243 1243
 			$argument_values = array();
1244 1244
 
1245 1245
 			// set widget instance
1246 1246
 			$this->instance = $instance;
1247 1247
 
1248
-			if ( empty( $this->arguments ) ) {
1248
+			if (empty($this->arguments)) {
1249 1249
 				$this->arguments = $this->get_arguments();
1250 1250
 			}
1251 1251
 
1252
-			if ( ! empty( $this->arguments ) ) {
1253
-				foreach ( $this->arguments as $key => $args ) {
1252
+			if (!empty($this->arguments)) {
1253
+				foreach ($this->arguments as $key => $args) {
1254 1254
 					// set the input name from the key
1255 1255
 					$args['name'] = $key;
1256 1256
 					//
1257
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1258
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1259
-						$argument_values[ $key ] = $args['default'];
1257
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1258
+					if ($argument_values[$key] == '' && isset($args['default'])) {
1259
+						$argument_values[$key] = $args['default'];
1260 1260
 					}
1261 1261
 				}
1262 1262
 			}
@@ -1283,12 +1283,12 @@  discard block
 block discarded – undo
1283 1283
 		 * @return array Get arguments.
1284 1284
 		 */
1285 1285
 		public function get_arguments() {
1286
-			if ( empty( $this->arguments ) ) {
1286
+			if (empty($this->arguments)) {
1287 1287
 				$this->arguments = $this->set_arguments();
1288 1288
 			}
1289 1289
 
1290
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1291
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1290
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1291
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1292 1292
 
1293 1293
 			return $this->arguments;
1294 1294
 		}
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
 		 * @param array $widget_args
1301 1301
 		 * @param string $content
1302 1302
 		 */
1303
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1303
+		public function output($args = array(), $widget_args = array(), $content = '') {
1304 1304
 
1305 1305
 		}
1306 1306
 
@@ -1308,10 +1308,10 @@  discard block
 block discarded – undo
1308 1308
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1309 1309
 		 */
1310 1310
 		public function register_block() {
1311
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1312
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1311
+			wp_add_inline_script('wp-blocks', $this->block());
1312
+			if (class_exists('SiteOrigin_Panels')) {
1313 1313
 
1314
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1314
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1315 1315
 
1316 1316
 			}
1317 1317
 		}
@@ -1326,13 +1326,13 @@  discard block
 block discarded – undo
1326 1326
 			$show      = false;
1327 1327
 			$arguments = $this->arguments;
1328 1328
 
1329
-			if ( empty( $arguments ) ) {
1329
+			if (empty($arguments)) {
1330 1330
 				$arguments = $this->get_arguments();
1331 1331
 			}
1332 1332
 
1333
-			if ( ! empty( $arguments ) ) {
1334
-				foreach ( $arguments as $argument ) {
1335
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1333
+			if (!empty($arguments)) {
1334
+				foreach ($arguments as $argument) {
1335
+					if (isset($argument['advanced']) && $argument['advanced']) {
1336 1336
 						$show = true;
1337 1337
 					}
1338 1338
 				}
@@ -1384,12 +1384,12 @@  discard block
 block discarded – undo
1384 1384
 					 * @return {?WPBlock}          The block, if it has been successfully
1385 1385
 					 *                             registered; otherwise `undefined`.
1386 1386
 					 */
1387
-					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.
1388
-						title: '<?php echo $this->options['name'];?>', // Block title.
1389
-						description: '<?php echo esc_attr( $this->options['widget_ops']['description'] )?>', // Block title.
1390
-						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/.
1391
-						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.
1392
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
1387
+					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.
1388
+						title: '<?php echo $this->options['name']; ?>', // Block title.
1389
+						description: '<?php echo esc_attr($this->options['widget_ops']['description'])?>', // Block title.
1390
+						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/.
1391
+						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.
1392
+						<?php if (isset($this->options['block-keywords'])) {
1393 1393
 						echo "keywords : " . $this->options['block-keywords'] . ",";
1394 1394
 					}?>
1395 1395
 
@@ -1399,10 +1399,10 @@  discard block
 block discarded – undo
1399 1399
 
1400 1400
 						$show_alignment = false;
1401 1401
 
1402
-						if ( ! empty( $this->arguments ) ) {
1402
+						if (!empty($this->arguments)) {
1403 1403
 							echo "attributes : {";
1404 1404
 
1405
-							if ( $show_advanced ) {
1405
+							if ($show_advanced) {
1406 1406
 								echo "show_advanced: {";
1407 1407
 								echo "	type: 'boolean',";
1408 1408
 								echo "  default: false,";
@@ -1410,42 +1410,42 @@  discard block
 block discarded – undo
1410 1410
 							}
1411 1411
 
1412 1412
 							// block wrap element
1413
-							if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1413
+							if (isset($this->options['block-wrap'])) { //@todo we should validate this?
1414 1414
 								echo "block_wrap: {";
1415 1415
 								echo "	type: 'string',";
1416
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1416
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
1417 1417
 								echo "},";
1418 1418
 							}
1419 1419
 
1420 1420
 
1421
-							foreach ( $this->arguments as $key => $args ) {
1421
+							foreach ($this->arguments as $key => $args) {
1422 1422
 
1423 1423
 								// set if we should show alignment
1424
-								if ( $key == 'alignment' ) {
1424
+								if ($key == 'alignment') {
1425 1425
 									$show_alignment = true;
1426 1426
 								}
1427 1427
 
1428 1428
 								$extra = '';
1429 1429
 
1430
-								if ( $args['type'] == 'checkbox' ) {
1430
+								if ($args['type'] == 'checkbox') {
1431 1431
 									$type    = 'boolean';
1432
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1433
-								} elseif ( $args['type'] == 'number' ) {
1432
+									$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
1433
+								} elseif ($args['type'] == 'number') {
1434 1434
 									$type    = 'number';
1435
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1436
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1435
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1436
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
1437 1437
 									$type = 'array';
1438
-									if ( is_array( $args['default'] ) ) {
1439
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1438
+									if (is_array($args['default'])) {
1439
+										$default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
1440 1440
 									} else {
1441
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1441
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1442 1442
 									}
1443
-								} elseif ( $args['type'] == 'multiselect' ) {
1443
+								} elseif ($args['type'] == 'multiselect') {
1444 1444
 									$type    = 'array';
1445
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1445
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1446 1446
 								} else {
1447 1447
 									$type    = 'string';
1448
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1448
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1449 1449
 								}
1450 1450
 								echo $key . " : {";
1451 1451
 								echo "type : '$type',";
@@ -1475,12 +1475,12 @@  discard block
 block discarded – undo
1475 1475
 									is_fetching = true;
1476 1476
 									var data = {
1477 1477
 										'action': 'super_duper_output_shortcode',
1478
-										'shortcode': '<?php echo $this->options['base_id'];?>',
1478
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
1479 1479
 										'attributes': props.attributes,
1480
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1480
+										'post_id': <?php global $post; if (isset($post->ID)) {
1481 1481
 										echo $post->ID;
1482 1482
 									}?>,
1483
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1483
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
1484 1484
 									};
1485 1485
 
1486 1486
 									jQuery.post(ajaxurl, data, function (response) {
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
 
1490 1490
 										// if the content is empty then we place some placeholder text
1491 1491
 										if (env == '') {
1492
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>";
1492
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>";
1493 1493
 										}
1494 1494
 
1495 1495
 										props.setAttributes({content: env});
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 
1509 1509
 								el(wp.editor.BlockControls, {key: 'controls'},
1510 1510
 
1511
-									<?php if($show_alignment){?>
1511
+									<?php if ($show_alignment) {?>
1512 1512
 									el(
1513 1513
 										wp.editor.AlignmentToolbar,
1514 1514
 										{
@@ -1526,9 +1526,9 @@  discard block
 block discarded – undo
1526 1526
 
1527 1527
 									<?php
1528 1528
 
1529
-									if(! empty( $this->arguments )){
1529
+									if (!empty($this->arguments)) {
1530 1530
 
1531
-									if ( $show_advanced ) {
1531
+									if ($show_advanced) {
1532 1532
 									?>
1533 1533
 									el(
1534 1534
 										wp.components.ToggleControl,
@@ -1544,76 +1544,76 @@  discard block
 block discarded – undo
1544 1544
 
1545 1545
 									}
1546 1546
 
1547
-									foreach($this->arguments as $key => $args){
1548
-									$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1547
+									foreach ($this->arguments as $key => $args) {
1548
+									$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
1549 1549
 									$options = '';
1550 1550
 									$extra = '';
1551 1551
 									$require = '';
1552 1552
 									$onchange = "props.setAttributes({ $key: $key } )";
1553 1553
 									$value = "props.attributes.$key";
1554
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1555
-									if ( in_array( $args['type'], $text_type ) ) {
1554
+									$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color');
1555
+									if (in_array($args['type'], $text_type)) {
1556 1556
 										$type = 'TextControl';
1557 1557
 										// Save numbers as numbers and not strings
1558
-										if ( $args['type'] == 'number' ) {
1558
+										if ($args['type'] == 'number') {
1559 1559
 											$onchange = "props.setAttributes({ $key: Number($key) } )";
1560 1560
 										}
1561 1561
 									}
1562 1562
 //									elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we may have to add our own https://github.com/WordPress/gutenberg/issues/14378
1563 1563
 //										$type = 'ColorPicker';
1564 1564
 //									}
1565
-									elseif ( $args['type'] == 'checkbox' ) {
1565
+									elseif ($args['type'] == 'checkbox') {
1566 1566
 										$type = 'CheckboxControl';
1567 1567
 										$extra .= "checked: props.attributes.$key,";
1568 1568
 										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1569
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1569
+									} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
1570 1570
 										$type = 'SelectControl';
1571
-										if ( ! empty( $args['options'] ) ) {
1571
+										if (!empty($args['options'])) {
1572 1572
 											$options .= "options  : [";
1573
-											foreach ( $args['options'] as $option_val => $option_label ) {
1574
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1573
+											foreach ($args['options'] as $option_val => $option_label) {
1574
+												$options .= "{ value : '" . esc_attr($option_val) . "',     label : '" . esc_attr($option_label) . "'     },";
1575 1575
 											}
1576 1576
 											$options .= "],";
1577 1577
 										}
1578
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1578
+										if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1579 1579
 											$extra .= ' multiple: true, ';
1580 1580
 											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1581 1581
 											//$value = "['edit', 'delete']";
1582 1582
 										}
1583
-									} elseif ( $args['type'] == 'alignment' ) {
1583
+									} elseif ($args['type'] == 'alignment') {
1584 1584
 										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1585 1585
 									} else {
1586
-										continue;// if we have not implemented the control then don't break the JS.
1586
+										continue; // if we have not implemented the control then don't break the JS.
1587 1587
 									}
1588 1588
 
1589 1589
 									// add show only if advanced
1590
-									if ( ! empty( $args['advanced'] ) ) {
1590
+									if (!empty($args['advanced'])) {
1591 1591
 										echo "props.attributes.show_advanced && ";
1592 1592
 									}
1593 1593
 									// add setting require if defined
1594
-									if ( ! empty( $args['element_require'] ) ) {
1595
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1594
+									if (!empty($args['element_require'])) {
1595
+										echo $this->block_props_replace($args['element_require'], true) . " && ";
1596 1596
 									}
1597 1597
 									?>
1598 1598
 									el(
1599
-										wp.components.<?php echo esc_attr( $type );?>,
1599
+										wp.components.<?php echo esc_attr($type); ?>,
1600 1600
 										{
1601
-											label: '<?php echo esc_attr( $args['title'] );?>',
1602
-											help: '<?php if ( isset( $args['desc'] ) ) {
1603
-												echo esc_attr( $args['desc'] );
1601
+											label: '<?php echo esc_attr($args['title']); ?>',
1602
+											help: '<?php if (isset($args['desc'])) {
1603
+												echo esc_attr($args['desc']);
1604 1604
 											}?>',
1605
-											value: <?php echo $value;?>,
1606
-											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1607
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1605
+											value: <?php echo $value; ?>,
1606
+											<?php if ($type == 'TextControl' && $args['type'] != 'text') {
1607
+											echo "type: '" . esc_attr($args['type']) . "',";
1608 1608
 										}?>
1609
-											<?php if ( ! empty( $args['placeholder'] ) ) {
1610
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1609
+											<?php if (!empty($args['placeholder'])) {
1610
+											echo "placeholder: '" . esc_attr($args['placeholder']) . "',";
1611 1611
 										}?>
1612
-											<?php echo $options;?>
1613
-											<?php echo $extra;?>
1614
-											<?php echo $custom_attributes;?>
1615
-											onChange: function ( <?php echo $key;?> ) {
1616
-												<?php echo $onchange;?>
1612
+											<?php echo $options; ?>
1613
+											<?php echo $extra; ?>
1614
+											<?php echo $custom_attributes; ?>
1615
+											onChange: function ( <?php echo $key; ?> ) {
1616
+												<?php echo $onchange; ?>
1617 1617
 											}
1618 1618
 										}
1619 1619
 									),
@@ -1626,9 +1626,9 @@  discard block
 block discarded – undo
1626 1626
 
1627 1627
 								<?php
1628 1628
 								// If the user sets block-output array then build it
1629
-								if ( ! empty( $this->options['block-output'] ) ) {
1630
-								$this->block_element( $this->options['block-output'] );
1631
-							}else{
1629
+								if (!empty($this->options['block-output'])) {
1630
+								$this->block_element($this->options['block-output']);
1631
+							} else {
1632 1632
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1633 1633
 								?>
1634 1634
 								el('div', {
@@ -1652,14 +1652,14 @@  discard block
 block discarded – undo
1652 1652
 							var align = '';
1653 1653
 
1654 1654
 							// build the shortcode.
1655
-							var content = "[<?php echo $this->options['base_id'];?>";
1655
+							var content = "[<?php echo $this->options['base_id']; ?>";
1656 1656
 							<?php
1657 1657
 
1658
-							if(! empty( $this->arguments )){
1659
-							foreach($this->arguments as $key => $args){
1658
+							if (!empty($this->arguments)) {
1659
+							foreach ($this->arguments as $key => $args) {
1660 1660
 							?>
1661
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1662
-								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1661
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
1662
+								content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
1663 1663
 							}
1664 1664
 							<?php
1665 1665
 							}
@@ -1700,10 +1700,10 @@  discard block
 block discarded – undo
1700 1700
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1701 1701
 			 */
1702 1702
 
1703
-			return str_replace( array(
1703
+			return str_replace(array(
1704 1704
 				'<script>',
1705 1705
 				'</script>'
1706
-			), '', $output );
1706
+			), '', $output);
1707 1707
 		}
1708 1708
 
1709 1709
 		/**
@@ -1715,16 +1715,16 @@  discard block
 block discarded – undo
1715 1715
 		 *
1716 1716
 		 * @return string
1717 1717
 		 */
1718
-		public function array_to_attributes( $custom_attributes, $html = false ) {
1718
+		public function array_to_attributes($custom_attributes, $html = false) {
1719 1719
 			$attributes = '';
1720
-			if ( ! empty( $custom_attributes ) ) {
1720
+			if (!empty($custom_attributes)) {
1721 1721
 
1722
-				if ( $html ) {
1723
-					foreach ( $custom_attributes as $key => $val ) {
1722
+				if ($html) {
1723
+					foreach ($custom_attributes as $key => $val) {
1724 1724
 						$attributes .= " $key='$val' ";
1725 1725
 					}
1726 1726
 				} else {
1727
-					foreach ( $custom_attributes as $key => $val ) {
1727
+					foreach ($custom_attributes as $key => $val) {
1728 1728
 						$attributes .= "'$key': '$val',";
1729 1729
 					}
1730 1730
 				}
@@ -1740,86 +1740,86 @@  discard block
 block discarded – undo
1740 1740
 		 *
1741 1741
 		 * @param $args
1742 1742
 		 */
1743
-		public function block_element( $args ) {
1743
+		public function block_element($args) {
1744 1744
 
1745 1745
 
1746
-			if ( ! empty( $args ) ) {
1747
-				foreach ( $args as $element => $new_args ) {
1746
+			if (!empty($args)) {
1747
+				foreach ($args as $element => $new_args) {
1748 1748
 
1749
-					if ( is_array( $new_args ) ) { // its an element
1749
+					if (is_array($new_args)) { // its an element
1750 1750
 
1751 1751
 
1752
-						if ( isset( $new_args['element'] ) ) {
1752
+						if (isset($new_args['element'])) {
1753 1753
 
1754
-							if ( isset( $new_args['element_require'] ) ) {
1755
-								echo str_replace( array(
1754
+							if (isset($new_args['element_require'])) {
1755
+								echo str_replace(array(
1756 1756
 										"'+",
1757 1757
 										"+'"
1758
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1759
-								unset( $new_args['element_require'] );
1758
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
1759
+								unset($new_args['element_require']);
1760 1760
 							}
1761 1761
 
1762 1762
 							echo "\n el( '" . $new_args['element'] . "', {";
1763 1763
 
1764 1764
 							// get the attributes
1765
-							foreach ( $new_args as $new_key => $new_value ) {
1765
+							foreach ($new_args as $new_key => $new_value) {
1766 1766
 
1767 1767
 
1768
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1768
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
1769 1769
 									// do nothing
1770 1770
 								} else {
1771
-									echo $this->block_element( array( $new_key => $new_value ) );
1771
+									echo $this->block_element(array($new_key => $new_value));
1772 1772
 								}
1773 1773
 							}
1774 1774
 
1775
-							echo "},";// end attributes
1775
+							echo "},"; // end attributes
1776 1776
 
1777 1777
 							// get the content
1778 1778
 							$first_item = 0;
1779
-							foreach ( $new_args as $new_key => $new_value ) {
1780
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1779
+							foreach ($new_args as $new_key => $new_value) {
1780
+								if ($new_key === 'content' || is_array($new_value)) {
1781 1781
 
1782
-									if ( $new_key === 'content' ) {
1783
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1782
+									if ($new_key === 'content') {
1783
+										echo "'" . $this->block_props_replace($new_value) . "'";
1784 1784
 									}
1785 1785
 
1786
-									if ( is_array( $new_value ) ) {
1786
+									if (is_array($new_value)) {
1787 1787
 
1788
-										if ( isset( $new_value['element_require'] ) ) {
1789
-											echo str_replace( array(
1788
+										if (isset($new_value['element_require'])) {
1789
+											echo str_replace(array(
1790 1790
 													"'+",
1791 1791
 													"+'"
1792
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1793
-											unset( $new_value['element_require'] );
1792
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
1793
+											unset($new_value['element_require']);
1794 1794
 										}
1795 1795
 
1796
-										if ( isset( $new_value['element_repeat'] ) ) {
1796
+										if (isset($new_value['element_repeat'])) {
1797 1797
 											$x = 1;
1798
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1799
-												$this->block_element( array( '' => $new_value ) );
1800
-												$x ++;
1798
+											while ($x <= absint($new_value['element_repeat'])) {
1799
+												$this->block_element(array('' => $new_value));
1800
+												$x++;
1801 1801
 											}
1802 1802
 										} else {
1803
-											$this->block_element( array( '' => $new_value ) );
1803
+											$this->block_element(array('' => $new_value));
1804 1804
 										}
1805 1805
 									}
1806
-									$first_item ++;
1806
+									$first_item++;
1807 1807
 								}
1808 1808
 							}
1809 1809
 
1810
-							echo ")";// end content
1810
+							echo ")"; // end content
1811 1811
 
1812 1812
 							echo ", \n";
1813 1813
 
1814 1814
 						}
1815 1815
 					} else {
1816 1816
 
1817
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1818
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1819
-						} elseif ( $element == 'style' ) {
1820
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1817
+						if (substr($element, 0, 3) === "if_") {
1818
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
1819
+						} elseif ($element == 'style') {
1820
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
1821 1821
 						} else {
1822
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1822
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
1823 1823
 						}
1824 1824
 
1825 1825
 					}
@@ -1834,12 +1834,12 @@  discard block
 block discarded – undo
1834 1834
 		 *
1835 1835
 		 * @return mixed
1836 1836
 		 */
1837
-		public function block_props_replace( $string, $no_wrap = false ) {
1837
+		public function block_props_replace($string, $no_wrap = false) {
1838 1838
 
1839
-			if ( $no_wrap ) {
1840
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1839
+			if ($no_wrap) {
1840
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
1841 1841
 			} else {
1842
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1842
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
1843 1843
 			}
1844 1844
 
1845 1845
 			return $string;
@@ -1851,37 +1851,37 @@  discard block
 block discarded – undo
1851 1851
 		 * @param array $args
1852 1852
 		 * @param array $instance
1853 1853
 		 */
1854
-		public function widget( $args, $instance ) {
1854
+		public function widget($args, $instance) {
1855 1855
 
1856 1856
 			// get the filtered values
1857
-			$argument_values = $this->argument_values( $instance );
1858
-			$argument_values = $this->string_to_bool( $argument_values );
1859
-			$output          = $this->output( $argument_values, $args );
1857
+			$argument_values = $this->argument_values($instance);
1858
+			$argument_values = $this->string_to_bool($argument_values);
1859
+			$output          = $this->output($argument_values, $args);
1860 1860
 
1861
-			if ( $output ) {
1861
+			if ($output) {
1862 1862
 				// Before widget
1863 1863
 				$before_widget = $args['before_widget'];
1864
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1865
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1864
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
1865
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
1866 1866
 
1867 1867
 				// After widget
1868 1868
 				$after_widget = $args['after_widget'];
1869
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1870
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1869
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
1870
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
1871 1871
 
1872 1872
 				echo $before_widget;
1873 1873
 				// elementor strips the widget wrapping div so we check for and add it back if needed
1874
-				if ( $this->is_elementor_widget_output() ) {
1875
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
1874
+				if ($this->is_elementor_widget_output()) {
1875
+					echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($this->options['widget_ops']['classname']) . "'>" : '';
1876 1876
 				}
1877
-				echo $this->output_title( $args, $instance );
1877
+				echo $this->output_title($args, $instance);
1878 1878
 				echo $output;
1879
-				if ( $this->is_elementor_widget_output() ) {
1880
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
1879
+				if ($this->is_elementor_widget_output()) {
1880
+					echo !empty($this->options['widget_ops']['classname']) ? "</span>" : '';
1881 1881
 				}
1882 1882
 				echo $after_widget;
1883
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
1884
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1883
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
1884
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
1885 1885
 				echo $output;
1886 1886
 			}
1887 1887
 		}
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
 		 */
1895 1895
 		public function is_elementor_widget_output() {
1896 1896
 			$result = false;
1897
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
1897
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
1898 1898
 				$result = true;
1899 1899
 			}
1900 1900
 
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 		 */
1910 1910
 		public function is_elementor_preview() {
1911 1911
 			$result = false;
1912
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
1912
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
1913 1913
 				$result = true;
1914 1914
 			}
1915 1915
 
@@ -1924,7 +1924,7 @@  discard block
 block discarded – undo
1924 1924
 		 */
1925 1925
 		public function is_divi_preview() {
1926 1926
 			$result = false;
1927
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
1927
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
1928 1928
 				$result = true;
1929 1929
 			}
1930 1930
 
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
 		 */
1940 1940
 		public function is_beaver_preview() {
1941 1941
 			$result = false;
1942
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
1942
+			if (isset($_REQUEST['fl_builder'])) {
1943 1943
 				$result = true;
1944 1944
 			}
1945 1945
 
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 		 */
1955 1955
 		public function is_siteorigin_preview() {
1956 1956
 			$result = false;
1957
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
1957
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
1958 1958
 				$result = true;
1959 1959
 			}
1960 1960
 
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 		 */
1970 1970
 		public function is_cornerstone_preview() {
1971 1971
 			$result = false;
1972
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
1972
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
1973 1973
 				$result = true;
1974 1974
 			}
1975 1975
 
@@ -1984,15 +1984,15 @@  discard block
 block discarded – undo
1984 1984
 		 */
1985 1985
 		public function is_preview() {
1986 1986
 			$preview = false;
1987
-			if ( $this->is_divi_preview() ) {
1987
+			if ($this->is_divi_preview()) {
1988 1988
 				$preview = true;
1989
-			} elseif ( $this->is_elementor_preview() ) {
1989
+			} elseif ($this->is_elementor_preview()) {
1990 1990
 				$preview = true;
1991
-			} elseif ( $this->is_beaver_preview() ) {
1991
+			} elseif ($this->is_beaver_preview()) {
1992 1992
 				$preview = true;
1993
-			} elseif ( $this->is_siteorigin_preview() ) {
1993
+			} elseif ($this->is_siteorigin_preview()) {
1994 1994
 				$preview = true;
1995
-			} elseif ( $this->is_cornerstone_preview() ) {
1995
+			} elseif ($this->is_cornerstone_preview()) {
1996 1996
 				$preview = true;
1997 1997
 			}
1998 1998
 
@@ -2007,11 +2007,11 @@  discard block
 block discarded – undo
2007 2007
 		 *
2008 2008
 		 * @return string
2009 2009
 		 */
2010
-		public function output_title( $args, $instance = array() ) {
2010
+		public function output_title($args, $instance = array()) {
2011 2011
 			$output = '';
2012
-			if ( ! empty( $instance['title'] ) ) {
2012
+			if (!empty($instance['title'])) {
2013 2013
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2014
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2014
+				$title  = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
2015 2015
 				$output = $args['before_title'] . $title . $args['after_title'];
2016 2016
 			}
2017 2017
 
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 		 *
2024 2024
 		 * @param array $instance The widget options.
2025 2025
 		 */
2026
-		public function form( $instance ) {
2026
+		public function form($instance) {
2027 2027
 
2028 2028
 			// set widget instance
2029 2029
 			$this->instance = $instance;
@@ -2031,12 +2031,12 @@  discard block
 block discarded – undo
2031 2031
 			// set it as a SD widget
2032 2032
 			echo $this->widget_advanced_toggle();
2033 2033
 
2034
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2034
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
2035 2035
 			$arguments = $this->get_arguments();
2036 2036
 
2037
-			if ( is_array( $arguments ) ) {
2038
-				foreach ( $arguments as $key => $args ) {
2039
-					$this->widget_inputs( $args, $instance );
2037
+			if (is_array($arguments)) {
2038
+				foreach ($arguments as $key => $args) {
2039
+					$this->widget_inputs($args, $instance);
2040 2040
 				}
2041 2041
 			}
2042 2042
 		}
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
 		public function widget_advanced_toggle() {
2050 2050
 
2051 2051
 			$output = '';
2052
-			if ( $this->block_show_advanced() ) {
2052
+			if ($this->block_show_advanced()) {
2053 2053
 				$val = 1;
2054 2054
 			} else {
2055 2055
 				$val = 0;
@@ -2069,14 +2069,14 @@  discard block
 block discarded – undo
2069 2069
 		 *
2070 2070
 		 * @return string $output
2071 2071
 		 */
2072
-		public function convert_element_require( $input ) {
2072
+		public function convert_element_require($input) {
2073 2073
 
2074
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2074
+			$input = str_replace("'", '"', $input); // we only want double quotes
2075 2075
 
2076
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2076
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
2077 2077
 				"jQuery(form).find('[data-argument=\"",
2078 2078
 				"\"]').find('input,select').val()"
2079
-			), $input ) );
2079
+			), $input));
2080 2080
 
2081 2081
 			return $output;
2082 2082
 		}
@@ -2087,54 +2087,54 @@  discard block
 block discarded – undo
2087 2087
 		 * @param $args
2088 2088
 		 * @param $instance
2089 2089
 		 */
2090
-		public function widget_inputs( $args, $instance ) {
2090
+		public function widget_inputs($args, $instance) {
2091 2091
 
2092 2092
 			$class             = "";
2093 2093
 			$element_require   = "";
2094 2094
 			$custom_attributes = "";
2095 2095
 
2096 2096
 			// get value
2097
-			if ( isset( $instance[ $args['name'] ] ) ) {
2098
-				$value = $instance[ $args['name'] ];
2099
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2100
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2097
+			if (isset($instance[$args['name']])) {
2098
+				$value = $instance[$args['name']];
2099
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
2100
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
2101 2101
 			} else {
2102 2102
 				$value = '';
2103 2103
 			}
2104 2104
 
2105 2105
 			// get placeholder
2106
-			if ( ! empty( $args['placeholder'] ) ) {
2107
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2106
+			if (!empty($args['placeholder'])) {
2107
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
2108 2108
 			} else {
2109 2109
 				$placeholder = '';
2110 2110
 			}
2111 2111
 
2112 2112
 			// get if advanced
2113
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2113
+			if (isset($args['advanced']) && $args['advanced']) {
2114 2114
 				$class .= " sd-advanced-setting ";
2115 2115
 			}
2116 2116
 
2117 2117
 			// element_require
2118
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2118
+			if (isset($args['element_require']) && $args['element_require']) {
2119 2119
 				$element_require = $args['element_require'];
2120 2120
 			}
2121 2121
 
2122 2122
 			// custom_attributes
2123
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2124
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2123
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
2124
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
2125 2125
 			}
2126 2126
 
2127 2127
 			// before wrapper
2128 2128
 			?>
2129
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2130
-			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2131
-			   data-element_require='<?php if ( $element_require ) {
2132
-				   echo $this->convert_element_require( $element_require );
2129
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
2130
+			   data-argument='<?php echo esc_attr($args['name']); ?>'
2131
+			   data-element_require='<?php if ($element_require) {
2132
+				   echo $this->convert_element_require($element_require);
2133 2133
 			   } ?>'
2134 2134
 			>
2135 2135
 				<?php
2136 2136
 
2137
-				switch ( $args['type'] ) {
2137
+				switch ($args['type']) {
2138 2138
 					//array('text','password','number','email','tel','url','color')
2139 2139
 					case "text":
2140 2140
 					case "password":
@@ -2145,46 +2145,46 @@  discard block
 block discarded – undo
2145 2145
 					case "color":
2146 2146
 						?>
2147 2147
 						<label
2148
-							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>
2148
+							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>
2149 2149
 						<input <?php echo $placeholder; ?> class="widefat"
2150 2150
 							<?php echo $custom_attributes; ?>
2151
-							                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2152
-							                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
2153
-							                               type="<?php echo esc_attr( $args['type'] ); ?>"
2154
-							                               value="<?php echo esc_attr( $value ); ?>">
2151
+							                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2152
+							                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
2153
+							                               type="<?php echo esc_attr($args['type']); ?>"
2154
+							                               value="<?php echo esc_attr($value); ?>">
2155 2155
 						<?php
2156 2156
 
2157 2157
 						break;
2158 2158
 					case "select":
2159
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2160
-						if ( $multiple ) {
2161
-							if ( empty( $value ) ) {
2159
+						$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
2160
+						if ($multiple) {
2161
+							if (empty($value)) {
2162 2162
 								$value = array();
2163 2163
 							}
2164 2164
 						}
2165 2165
 						?>
2166 2166
 						<label
2167
-							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>
2167
+							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>
2168 2168
 						<select <?php echo $placeholder; ?> class="widefat"
2169 2169
 							<?php echo $custom_attributes; ?>
2170
-							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2171
-							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2172
-							                                if ( $multiple ) {
2170
+							                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2171
+							                                name="<?php echo esc_attr($this->get_field_name($args['name']));
2172
+							                                if ($multiple) {
2173 2173
 								                                echo "[]";
2174 2174
 							                                } ?>"
2175
-							<?php if ( $multiple ) {
2175
+							<?php if ($multiple) {
2176 2176
 								echo "multiple";
2177 2177
 							} //@todo not implemented yet due to gutenberg not supporting it
2178 2178
 							?>
2179 2179
 						>
2180 2180
 							<?php
2181 2181
 
2182
-							if ( ! empty( $args['options'] ) ) {
2183
-								foreach ( $args['options'] as $val => $label ) {
2184
-									if ( $multiple ) {
2185
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2182
+							if (!empty($args['options'])) {
2183
+								foreach ($args['options'] as $val => $label) {
2184
+									if ($multiple) {
2185
+										$selected = in_array($val, $value) ? 'selected="selected"' : '';
2186 2186
 									} else {
2187
-										$selected = selected( $value, $val, false );
2187
+										$selected = selected($value, $val, false);
2188 2188
 									}
2189 2189
 									echo "<option value='$val' " . $selected . ">$label</option>";
2190 2190
 								}
@@ -2196,20 +2196,20 @@  discard block
 block discarded – undo
2196 2196
 					case "checkbox":
2197 2197
 						?>
2198 2198
 						<input <?php echo $placeholder; ?>
2199
-							<?php checked( 1, $value, true ) ?>
2199
+							<?php checked(1, $value, true) ?>
2200 2200
 							<?php echo $custom_attributes; ?>
2201
-							class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2202
-							name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
2201
+							class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2202
+							name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
2203 2203
 							value="1">
2204 2204
 						<label
2205
-							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>
2205
+							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>
2206 2206
 						<?php
2207 2207
 						break;
2208 2208
 					case "hidden":
2209 2209
 						?>
2210
-						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2211
-						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2212
-						       value="<?php echo esc_attr( $value ); ?>">
2210
+						<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2211
+						       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
2212
+						       value="<?php echo esc_attr($value); ?>">
2213 2213
 						<?php
2214 2214
 						break;
2215 2215
 					default:
@@ -2231,14 +2231,14 @@  discard block
 block discarded – undo
2231 2231
 		 * @return string
2232 2232
 		 * @todo, need to make its own tooltip script
2233 2233
 		 */
2234
-		public function widget_field_desc( $args ) {
2234
+		public function widget_field_desc($args) {
2235 2235
 
2236 2236
 			$description = '';
2237
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2238
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2239
-					$description = $this->desc_tip( $args['desc'] );
2237
+			if (isset($args['desc']) && $args['desc']) {
2238
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
2239
+					$description = $this->desc_tip($args['desc']);
2240 2240
 				} else {
2241
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2241
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
2242 2242
 				}
2243 2243
 			}
2244 2244
 
@@ -2253,11 +2253,11 @@  discard block
 block discarded – undo
2253 2253
 		 *
2254 2254
 		 * @return string
2255 2255
 		 */
2256
-		function desc_tip( $tip, $allow_html = false ) {
2257
-			if ( $allow_html ) {
2258
-				$tip = $this->sanitize_tooltip( $tip );
2256
+		function desc_tip($tip, $allow_html = false) {
2257
+			if ($allow_html) {
2258
+				$tip = $this->sanitize_tooltip($tip);
2259 2259
 			} else {
2260
-				$tip = esc_attr( $tip );
2260
+				$tip = esc_attr($tip);
2261 2261
 			}
2262 2262
 
2263 2263
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -2270,8 +2270,8 @@  discard block
 block discarded – undo
2270 2270
 		 *
2271 2271
 		 * @return string
2272 2272
 		 */
2273
-		public function sanitize_tooltip( $var ) {
2274
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2273
+		public function sanitize_tooltip($var) {
2274
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
2275 2275
 				'br'     => array(),
2276 2276
 				'em'     => array(),
2277 2277
 				'strong' => array(),
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 				'li'     => array(),
2282 2282
 				'ol'     => array(),
2283 2283
 				'p'      => array(),
2284
-			) ) );
2284
+			)));
2285 2285
 		}
2286 2286
 
2287 2287
 		/**
@@ -2293,23 +2293,23 @@  discard block
 block discarded – undo
2293 2293
 		 * @return array
2294 2294
 		 * @todo we should add some sanitation here.
2295 2295
 		 */
2296
-		public function update( $new_instance, $old_instance ) {
2296
+		public function update($new_instance, $old_instance) {
2297 2297
 
2298 2298
 			//save the widget
2299
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2299
+			$instance = array_merge((array)$old_instance, (array)$new_instance);
2300 2300
 
2301 2301
 			// set widget instance
2302 2302
 			$this->instance = $instance;
2303 2303
 
2304
-			if ( empty( $this->arguments ) ) {
2304
+			if (empty($this->arguments)) {
2305 2305
 				$this->get_arguments();
2306 2306
 			}
2307 2307
 
2308 2308
 			// check for checkboxes
2309
-			if ( ! empty( $this->arguments ) ) {
2310
-				foreach ( $this->arguments as $argument ) {
2311
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2312
-						$instance[ $argument['name'] ] = '0';
2309
+			if (!empty($this->arguments)) {
2310
+				foreach ($this->arguments as $argument) {
2311
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
2312
+						$instance[$argument['name']] = '0';
2313 2313
 					}
2314 2314
 				}
2315 2315
 			}
@@ -2327,7 +2327,7 @@  discard block
 block discarded – undo
2327 2327
 		 */
2328 2328
 		public function is_block_content_call() {
2329 2329
 			$result = false;
2330
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2330
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
2331 2331
 				$result = true;
2332 2332
 			}
2333 2333
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 2 patches
Indentation   +353 added lines, -353 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,285 +21,285 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @since 1.0.10 Now able to pass wp.org theme check.
29
-	 * @ver 1.0.10
30
-	 * @todo decide how to implement textdomain
31
-	 */
32
-	class WP_Font_Awesome_Settings {
33
-
34
-		/**
35
-		 * Class version version.
36
-		 *
37
-		 * @var string
38
-		 */
39
-		public $version = '1.0.10';
40
-
41
-		/**
42
-		 * Class textdomain.
43
-		 *
44
-		 * @var string
45
-		 */
46
-		public $textdomain = 'font-awesome-settings';
47
-
48
-		/**
49
-		 * Latest version of Font Awesome at time of publish published.
50
-		 *
51
-		 * @var string
52
-		 */
53
-		public $latest = "5.6.1";
54
-
55
-		/**
56
-		 * The title.
57
-		 *
58
-		 * @var string
59
-		 */
60
-		public $name = 'Font Awesome';
61
-
62
-		/**
63
-		 * Holds the settings values.
64
-		 *
65
-		 * @var array
66
-		 */
67
-		private $settings;
68
-
69
-		/**
70
-		 * WP_Font_Awesome_Settings instance.
71
-		 *
72
-		 * @access private
73
-		 * @since  1.0.0
74
-		 * @var    WP_Font_Awesome_Settings There can be only one!
75
-		 */
76
-		private static $instance = null;
77
-
78
-		/**
79
-		 * Main WP_Font_Awesome_Settings Instance.
80
-		 *
81
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
82
-		 *
83
-		 * @since 1.0.0
84
-		 * @static
85
-		 * @return WP_Font_Awesome_Settings - Main instance.
86
-		 */
87
-		public static function instance() {
88
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
89
-				self::$instance = new WP_Font_Awesome_Settings;
90
-
91
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
92
-
93
-				if ( is_admin() ) {
94
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
95
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
96
-				}
97
-
98
-				do_action( 'wp_font_awesome_settings_loaded' );
99
-			}
100
-
101
-			return self::$instance;
102
-		}
103
-
104
-		/**
105
-		 * Initiate the settings and add the required action hooks.
106
-		 *
107
-		 * @since 1.0.8 Settings name wrong - FIXED
108
-		 */
109
-		public function init() {
110
-			$this->settings = $this->get_settings();
111
-
112
-			if ( $this->settings['type'] == 'CSS' ) {
113
-
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
116
-				}
117
-
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
-				}
121
-
122
-			} else {
123
-
124
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
125
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
126
-				}
127
-
128
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
129
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
-				}
131
-			}
132
-
133
-			// remove font awesome if set to do so
134
-			if ( $this->settings['dequeue'] == '1' ) {
135
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
-			}
137
-
138
-		}
139
-
140
-		/**
141
-		 * Adds the Font Awesome styles.
142
-		 */
143
-		public function enqueue_style() {
144
-			// build url
145
-			$url = $this->get_url();
146
-
147
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
148
-			wp_register_style( 'font-awesome', $url, array(), null );
149
-			wp_enqueue_style( 'font-awesome' );
150
-
151
-			if ( $this->settings['shims'] ) {
152
-				$url = $this->get_url( true );
153
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
154
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
155
-				wp_enqueue_style( 'font-awesome-shims' );
156
-			}
157
-		}
158
-
159
-		/**
160
-		 * Adds the Font Awesome JS.
161
-		 */
162
-		public function enqueue_scripts() {
163
-			// build url
164
-			$url = $this->get_url();
165
-
166
-			$deregister_function = 'wp'.'_'.'deregister'.'_'.'script';
167
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
168
-			wp_register_script( 'font-awesome', $url, array(), null );
169
-			wp_enqueue_script( 'font-awesome' );
170
-
171
-			if ( $this->settings['shims'] ) {
172
-				$url = $this->get_url( true );
173
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
174
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
175
-				wp_enqueue_script( 'font-awesome-shims' );
176
-			}
177
-		}
178
-
179
-		/**
180
-		 * Get the url of the Font Awesome files.
181
-		 *
182
-		 * @param bool $shims If this is a shim file or not.
183
-		 *
184
-		 * @return string The url to the file.
185
-		 */
186
-		public function get_url( $shims = false ) {
187
-			$script  = $shims ? 'v4-shims' : 'all';
188
-			$type    = $this->settings['type'];
189
-			$version = $this->settings['version'];
190
-
191
-			$url = "https://use.fontawesome.com/releases/"; // CDN
192
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
193
-			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
194
-			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
195
-			$url .= "?wpfas=true"; // set our var so our version is not removed
196
-
197
-			return $url;
198
-		}
199
-
200
-		/**
201
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
202
-		 *
203
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
204
-		 *
205
-		 * @param $url
206
-		 * @param $original_url
207
-		 * @param $_context
208
-		 *
209
-		 * @return string The filtered url.
210
-		 */
211
-		public function remove_font_awesome( $url, $original_url, $_context ) {
212
-
213
-			if ( $_context == 'display'
214
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
215
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
216
-			) {// it's a font-awesome-url (probably)
217
-
218
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
219
-					if ( $this->settings['type'] == 'JS' ) {
220
-						if ( $this->settings['js-pseudo'] ) {
221
-							$url .= "' data-search-pseudo-elements defer='defer";
222
-						} else {
223
-							$url .= "' defer='defer";
224
-						}
225
-					}
226
-				} else {
227
-					$url = ''; // removing the url removes the file
228
-				}
229
-
230
-			}
231
-
232
-			return $url;
233
-		}
234
-
235
-		/**
236
-		 * Register the database settings with WordPress.
237
-		 */
238
-		public function register_settings() {
239
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
240
-		}
241
-
242
-		/**
243
-		 * Add the WordPress settings menu item.
244
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
245
-		 */
246
-		public function menu_item() {
247
-			$menu_function = 'add'.'_'.'options'.'_'.'page'; // won't pass theme check if function name present in theme
248
-			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
249
-				$this,
250
-				'settings_page'
251
-			) );
252
-		}
253
-
254
-		/**
255
-		 * Get the current Font Awesome output settings.
256
-		 *
257
-		 * @return array The array of settings.
258
-		 */
259
-		public function get_settings() {
260
-
261
-			$db_settings = get_option( 'wp-font-awesome-settings' );
262
-
263
-			$defaults = array(
264
-				'type'      => 'CSS', // type to use, CSS or JS
265
-				'version'   => '', // latest
266
-				'enqueue'   => '', // front and backend
267
-				'shims'     => '1', // default on for now, @todo maybe change to off in 2020
268
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
269
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
270
-			);
271
-
272
-			$settings = wp_parse_args( $db_settings, $defaults );
273
-
274
-			/**
275
-			 * Filter the Font Awesome settings.
276
-			 *
277
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
278
-			 */
279
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
280
-		}
281
-
282
-
283
-		/**
284
-		 * The settings page html output.
285
-		 */
286
-		public function settings_page() {
287
-			if ( ! current_user_can( 'manage_options' ) ) {
288
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
289
-			}
290
-
291
-			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
292
-			if(isset($_REQUEST['force-version-check'])){
293
-				$this->get_latest_version($force_api = true);
294
-			}
295
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @since 1.0.10 Now able to pass wp.org theme check.
29
+     * @ver 1.0.10
30
+     * @todo decide how to implement textdomain
31
+     */
32
+    class WP_Font_Awesome_Settings {
33
+
34
+        /**
35
+         * Class version version.
36
+         *
37
+         * @var string
38
+         */
39
+        public $version = '1.0.10';
40
+
41
+        /**
42
+         * Class textdomain.
43
+         *
44
+         * @var string
45
+         */
46
+        public $textdomain = 'font-awesome-settings';
47
+
48
+        /**
49
+         * Latest version of Font Awesome at time of publish published.
50
+         *
51
+         * @var string
52
+         */
53
+        public $latest = "5.6.1";
54
+
55
+        /**
56
+         * The title.
57
+         *
58
+         * @var string
59
+         */
60
+        public $name = 'Font Awesome';
61
+
62
+        /**
63
+         * Holds the settings values.
64
+         *
65
+         * @var array
66
+         */
67
+        private $settings;
68
+
69
+        /**
70
+         * WP_Font_Awesome_Settings instance.
71
+         *
72
+         * @access private
73
+         * @since  1.0.0
74
+         * @var    WP_Font_Awesome_Settings There can be only one!
75
+         */
76
+        private static $instance = null;
77
+
78
+        /**
79
+         * Main WP_Font_Awesome_Settings Instance.
80
+         *
81
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
82
+         *
83
+         * @since 1.0.0
84
+         * @static
85
+         * @return WP_Font_Awesome_Settings - Main instance.
86
+         */
87
+        public static function instance() {
88
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
89
+                self::$instance = new WP_Font_Awesome_Settings;
90
+
91
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
92
+
93
+                if ( is_admin() ) {
94
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
95
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
96
+                }
97
+
98
+                do_action( 'wp_font_awesome_settings_loaded' );
99
+            }
100
+
101
+            return self::$instance;
102
+        }
103
+
104
+        /**
105
+         * Initiate the settings and add the required action hooks.
106
+         *
107
+         * @since 1.0.8 Settings name wrong - FIXED
108
+         */
109
+        public function init() {
110
+            $this->settings = $this->get_settings();
111
+
112
+            if ( $this->settings['type'] == 'CSS' ) {
113
+
114
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
115
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
116
+                }
117
+
118
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
119
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
+                }
121
+
122
+            } else {
123
+
124
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
125
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
126
+                }
127
+
128
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
129
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
+                }
131
+            }
132
+
133
+            // remove font awesome if set to do so
134
+            if ( $this->settings['dequeue'] == '1' ) {
135
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
+            }
137
+
138
+        }
139
+
140
+        /**
141
+         * Adds the Font Awesome styles.
142
+         */
143
+        public function enqueue_style() {
144
+            // build url
145
+            $url = $this->get_url();
146
+
147
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
148
+            wp_register_style( 'font-awesome', $url, array(), null );
149
+            wp_enqueue_style( 'font-awesome' );
150
+
151
+            if ( $this->settings['shims'] ) {
152
+                $url = $this->get_url( true );
153
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
154
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
155
+                wp_enqueue_style( 'font-awesome-shims' );
156
+            }
157
+        }
158
+
159
+        /**
160
+         * Adds the Font Awesome JS.
161
+         */
162
+        public function enqueue_scripts() {
163
+            // build url
164
+            $url = $this->get_url();
165
+
166
+            $deregister_function = 'wp'.'_'.'deregister'.'_'.'script';
167
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
168
+            wp_register_script( 'font-awesome', $url, array(), null );
169
+            wp_enqueue_script( 'font-awesome' );
170
+
171
+            if ( $this->settings['shims'] ) {
172
+                $url = $this->get_url( true );
173
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
174
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
175
+                wp_enqueue_script( 'font-awesome-shims' );
176
+            }
177
+        }
178
+
179
+        /**
180
+         * Get the url of the Font Awesome files.
181
+         *
182
+         * @param bool $shims If this is a shim file or not.
183
+         *
184
+         * @return string The url to the file.
185
+         */
186
+        public function get_url( $shims = false ) {
187
+            $script  = $shims ? 'v4-shims' : 'all';
188
+            $type    = $this->settings['type'];
189
+            $version = $this->settings['version'];
190
+
191
+            $url = "https://use.fontawesome.com/releases/"; // CDN
192
+            $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
193
+            $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
194
+            $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
195
+            $url .= "?wpfas=true"; // set our var so our version is not removed
196
+
197
+            return $url;
198
+        }
199
+
200
+        /**
201
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
202
+         *
203
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
204
+         *
205
+         * @param $url
206
+         * @param $original_url
207
+         * @param $_context
208
+         *
209
+         * @return string The filtered url.
210
+         */
211
+        public function remove_font_awesome( $url, $original_url, $_context ) {
212
+
213
+            if ( $_context == 'display'
214
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
215
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
216
+            ) {// it's a font-awesome-url (probably)
217
+
218
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
219
+                    if ( $this->settings['type'] == 'JS' ) {
220
+                        if ( $this->settings['js-pseudo'] ) {
221
+                            $url .= "' data-search-pseudo-elements defer='defer";
222
+                        } else {
223
+                            $url .= "' defer='defer";
224
+                        }
225
+                    }
226
+                } else {
227
+                    $url = ''; // removing the url removes the file
228
+                }
229
+
230
+            }
231
+
232
+            return $url;
233
+        }
234
+
235
+        /**
236
+         * Register the database settings with WordPress.
237
+         */
238
+        public function register_settings() {
239
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
240
+        }
241
+
242
+        /**
243
+         * Add the WordPress settings menu item.
244
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
245
+         */
246
+        public function menu_item() {
247
+            $menu_function = 'add'.'_'.'options'.'_'.'page'; // won't pass theme check if function name present in theme
248
+            call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
249
+                $this,
250
+                'settings_page'
251
+            ) );
252
+        }
253
+
254
+        /**
255
+         * Get the current Font Awesome output settings.
256
+         *
257
+         * @return array The array of settings.
258
+         */
259
+        public function get_settings() {
260
+
261
+            $db_settings = get_option( 'wp-font-awesome-settings' );
262
+
263
+            $defaults = array(
264
+                'type'      => 'CSS', // type to use, CSS or JS
265
+                'version'   => '', // latest
266
+                'enqueue'   => '', // front and backend
267
+                'shims'     => '1', // default on for now, @todo maybe change to off in 2020
268
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
269
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
270
+            );
271
+
272
+            $settings = wp_parse_args( $db_settings, $defaults );
273
+
274
+            /**
275
+             * Filter the Font Awesome settings.
276
+             *
277
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
278
+             */
279
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
280
+        }
281
+
282
+
283
+        /**
284
+         * The settings page html output.
285
+         */
286
+        public function settings_page() {
287
+            if ( ! current_user_can( 'manage_options' ) ) {
288
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
289
+            }
290
+
291
+            // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
292
+            if(isset($_REQUEST['force-version-check'])){
293
+                $this->get_latest_version($force_api = true);
294
+            }
295
+            ?>
296 296
 			<div class="wrap">
297 297
 				<h1><?php echo $this->name; ?></h1>
298 298
 				<form method="post" action="options.php">
299 299
 					<?php
300
-					settings_fields( 'wp-font-awesome-settings' );
301
-					do_settings_sections( 'wp-font-awesome-settings' );
302
-					?>
300
+                    settings_fields( 'wp-font-awesome-settings' );
301
+                    do_settings_sections( 'wp-font-awesome-settings' );
302
+                    ?>
303 303
 					<table class="form-table">
304 304
 						<tr valign="top">
305 305
 							<th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
@@ -396,87 +396,87 @@  discard block
 block discarded – undo
396 396
 
397 397
 					</table>
398 398
 					<?php
399
-					submit_button();
400
-					?>
399
+                    submit_button();
400
+                    ?>
401 401
 				</form>
402 402
 
403 403
 				<div id="wpfas-version"><?php echo $this->version; ?></div>
404 404
 			</div>
405 405
 
406 406
 			<?php
407
-		}
408
-
409
-		/**
410
-		 * Check a version number is valid and if so return it or else return an empty string.
411
-		 *
412
-		 * @param $version string The version number to check.
413
-		 * @since 1.0.6
414
-		 *
415
-		 * @return string Either a valid version number or an empty string.
416
-		 */
417
-		public function validate_version_number( $version ) {
418
-
419
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
420
-				// valid
421
-			} else {
422
-				$version = '';// not validated
423
-			}
424
-
425
-			return $version;
426
-		}
427
-
428
-
429
-		/**
430
-		 * Get the latest version of Font Awesome.
431
-		 *
432
-		 * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
433
-		 *
434
-		 * @since 1.0.7
435
-		 * @return mixed|string The latest version number found.
436
-		 */
437
-		public function get_latest_version($force_api = false) {
438
-			$latest_version = $this->latest;
439
-
440
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
441
-
442
-			if ( $cache === false || $force_api) { // its not set
443
-				$api_ver = $this->get_latest_version_from_api();
444
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
445
-					$latest_version = $api_ver;
446
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
447
-				}
448
-			} elseif ( $this->validate_version_number( $cache ) ) {
449
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
450
-					$latest_version = $cache;
451
-				}
452
-			}
453
-
454
-			return $latest_version;
455
-		}
456
-
457
-		/**
458
-		 * Get the latest Font Awesome version from the github API.
459
-		 *
460
-		 * @since 1.0.7
461
-		 * @return string The latest version number or `0` on API fail.
462
-		 */
463
-		public function get_latest_version_from_api() {
464
-			$version  = "0";
465
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
466
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
467
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
468
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
469
-					$version = $api_response['tag_name'];
470
-				}
471
-			}
472
-
473
-			return $version;
474
-		}
475
-
476
-	}
477
-
478
-	/**
479
-	 * Run the class if found.
480
-	 */
481
-	WP_Font_Awesome_Settings::instance();
407
+        }
408
+
409
+        /**
410
+         * Check a version number is valid and if so return it or else return an empty string.
411
+         *
412
+         * @param $version string The version number to check.
413
+         * @since 1.0.6
414
+         *
415
+         * @return string Either a valid version number or an empty string.
416
+         */
417
+        public function validate_version_number( $version ) {
418
+
419
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
420
+                // valid
421
+            } else {
422
+                $version = '';// not validated
423
+            }
424
+
425
+            return $version;
426
+        }
427
+
428
+
429
+        /**
430
+         * Get the latest version of Font Awesome.
431
+         *
432
+         * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
433
+         *
434
+         * @since 1.0.7
435
+         * @return mixed|string The latest version number found.
436
+         */
437
+        public function get_latest_version($force_api = false) {
438
+            $latest_version = $this->latest;
439
+
440
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
441
+
442
+            if ( $cache === false || $force_api) { // its not set
443
+                $api_ver = $this->get_latest_version_from_api();
444
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
445
+                    $latest_version = $api_ver;
446
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
447
+                }
448
+            } elseif ( $this->validate_version_number( $cache ) ) {
449
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
450
+                    $latest_version = $cache;
451
+                }
452
+            }
453
+
454
+            return $latest_version;
455
+        }
456
+
457
+        /**
458
+         * Get the latest Font Awesome version from the github API.
459
+         *
460
+         * @since 1.0.7
461
+         * @return string The latest version number or `0` on API fail.
462
+         */
463
+        public function get_latest_version_from_api() {
464
+            $version  = "0";
465
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
466
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
467
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
468
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
469
+                    $version = $api_response['tag_name'];
470
+                }
471
+            }
472
+
473
+            return $version;
474
+        }
475
+
476
+    }
477
+
478
+    /**
479
+     * Run the class if found.
480
+     */
481
+    WP_Font_Awesome_Settings::instance();
482 482
 }
483 483
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 		 * @return WP_Font_Awesome_Settings - Main instance.
86 86
 		 */
87 87
 		public static function instance() {
88
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
88
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
89 89
 				self::$instance = new WP_Font_Awesome_Settings;
90 90
 
91
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
91
+				add_action('init', array(self::$instance, 'init')); // set settings
92 92
 
93
-				if ( is_admin() ) {
94
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
95
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
+				if (is_admin()) {
94
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
95
+					add_action('admin_init', array(self::$instance, 'register_settings'));
96 96
 				}
97 97
 
98
-				do_action( 'wp_font_awesome_settings_loaded' );
98
+				do_action('wp_font_awesome_settings_loaded');
99 99
 			}
100 100
 
101 101
 			return self::$instance;
@@ -109,30 +109,30 @@  discard block
 block discarded – undo
109 109
 		public function init() {
110 110
 			$this->settings = $this->get_settings();
111 111
 
112
-			if ( $this->settings['type'] == 'CSS' ) {
112
+			if ($this->settings['type'] == 'CSS') {
113 113
 
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
114
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
115
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); //echo '###';exit;
116 116
 				}
117 117
 
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
118
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
119
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
120 120
 				}
121 121
 
122 122
 			} else {
123 123
 
124
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
125
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
124
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
125
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); //echo '###';exit;
126 126
 				}
127 127
 
128
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
129
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
128
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
129
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
130 130
 				}
131 131
 			}
132 132
 
133 133
 			// remove font awesome if set to do so
134
-			if ( $this->settings['dequeue'] == '1' ) {
135
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
134
+			if ($this->settings['dequeue'] == '1') {
135
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
136 136
 			}
137 137
 
138 138
 		}
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 			// build url
145 145
 			$url = $this->get_url();
146 146
 
147
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
148
-			wp_register_style( 'font-awesome', $url, array(), null );
149
-			wp_enqueue_style( 'font-awesome' );
147
+			wp_deregister_style('font-awesome'); // deregister in case its already there
148
+			wp_register_style('font-awesome', $url, array(), null);
149
+			wp_enqueue_style('font-awesome');
150 150
 
151
-			if ( $this->settings['shims'] ) {
152
-				$url = $this->get_url( true );
153
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
154
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
155
-				wp_enqueue_style( 'font-awesome-shims' );
151
+			if ($this->settings['shims']) {
152
+				$url = $this->get_url(true);
153
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
154
+				wp_register_style('font-awesome-shims', $url, array(), null);
155
+				wp_enqueue_style('font-awesome-shims');
156 156
 			}
157 157
 		}
158 158
 
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			// build url
164 164
 			$url = $this->get_url();
165 165
 
166
-			$deregister_function = 'wp'.'_'.'deregister'.'_'.'script';
167
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
168
-			wp_register_script( 'font-awesome', $url, array(), null );
169
-			wp_enqueue_script( 'font-awesome' );
166
+			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
167
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
168
+			wp_register_script('font-awesome', $url, array(), null);
169
+			wp_enqueue_script('font-awesome');
170 170
 
171
-			if ( $this->settings['shims'] ) {
172
-				$url = $this->get_url( true );
173
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
174
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
175
-				wp_enqueue_script( 'font-awesome-shims' );
171
+			if ($this->settings['shims']) {
172
+				$url = $this->get_url(true);
173
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
174
+				wp_register_script('font-awesome-shims', $url, array(), null);
175
+				wp_enqueue_script('font-awesome-shims');
176 176
 			}
177 177
 		}
178 178
 
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 		 *
184 184
 		 * @return string The url to the file.
185 185
 		 */
186
-		public function get_url( $shims = false ) {
186
+		public function get_url($shims = false) {
187 187
 			$script  = $shims ? 'v4-shims' : 'all';
188 188
 			$type    = $this->settings['type'];
189 189
 			$version = $this->settings['version'];
190 190
 
191 191
 			$url = "https://use.fontawesome.com/releases/"; // CDN
192
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
192
+			$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
193 193
 			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
194 194
 			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
195 195
 			$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
 		 *
209 209
 		 * @return string The filtered url.
210 210
 		 */
211
-		public function remove_font_awesome( $url, $original_url, $_context ) {
211
+		public function remove_font_awesome($url, $original_url, $_context) {
212 212
 
213
-			if ( $_context == 'display'
214
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
215
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
213
+			if ($_context == 'display'
214
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
215
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
216 216
 			) {// it's a font-awesome-url (probably)
217 217
 
218
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
219
-					if ( $this->settings['type'] == 'JS' ) {
220
-						if ( $this->settings['js-pseudo'] ) {
218
+				if (strstr($url, "wpfas=true") !== false) {
219
+					if ($this->settings['type'] == 'JS') {
220
+						if ($this->settings['js-pseudo']) {
221 221
 							$url .= "' data-search-pseudo-elements defer='defer";
222 222
 						} else {
223 223
 							$url .= "' defer='defer";
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 * Register the database settings with WordPress.
237 237
 		 */
238 238
 		public function register_settings() {
239
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
239
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
240 240
 		}
241 241
 
242 242
 		/**
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
245 245
 		 */
246 246
 		public function menu_item() {
247
-			$menu_function = 'add'.'_'.'options'.'_'.'page'; // won't pass theme check if function name present in theme
247
+			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
248 248
 			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
249 249
 				$this,
250 250
 				'settings_page'
251
-			) );
251
+			));
252 252
 		}
253 253
 
254 254
 		/**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		 */
259 259
 		public function get_settings() {
260 260
 
261
-			$db_settings = get_option( 'wp-font-awesome-settings' );
261
+			$db_settings = get_option('wp-font-awesome-settings');
262 262
 
263 263
 			$defaults = array(
264 264
 				'type'      => 'CSS', // type to use, CSS or JS
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
 				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
270 270
 			);
271 271
 
272
-			$settings = wp_parse_args( $db_settings, $defaults );
272
+			$settings = wp_parse_args($db_settings, $defaults);
273 273
 
274 274
 			/**
275 275
 			 * Filter the Font Awesome settings.
276 276
 			 *
277 277
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
278 278
 			 */
279
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
279
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
280 280
 		}
281 281
 
282 282
 
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 		 * The settings page html output.
285 285
 		 */
286 286
 		public function settings_page() {
287
-			if ( ! current_user_can( 'manage_options' ) ) {
288
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
287
+			if (!current_user_can('manage_options')) {
288
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
289 289
 			}
290 290
 
291 291
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
292
-			if(isset($_REQUEST['force-version-check'])){
292
+			if (isset($_REQUEST['force-version-check'])) {
293 293
 				$this->get_latest_version($force_api = true);
294 294
 			}
295 295
 			?>
@@ -297,47 +297,47 @@  discard block
 block discarded – undo
297 297
 				<h1><?php echo $this->name; ?></h1>
298 298
 				<form method="post" action="options.php">
299 299
 					<?php
300
-					settings_fields( 'wp-font-awesome-settings' );
301
-					do_settings_sections( 'wp-font-awesome-settings' );
300
+					settings_fields('wp-font-awesome-settings');
301
+					do_settings_sections('wp-font-awesome-settings');
302 302
 					?>
303 303
 					<table class="form-table">
304 304
 						<tr valign="top">
305
-							<th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
305
+							<th scope="row"><label for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
306 306
 							<td>
307 307
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type">
308 308
 									<option
309
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
310
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
309
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
310
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
311 311
 								</select>
312 312
 							</td>
313 313
 						</tr>
314 314
 
315 315
 						<tr valign="top">
316
-							<th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
316
+							<th scope="row"><label for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
317 317
 							<td>
318 318
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
319 319
 									<option
320
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?>
320
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?>
321 321
 									</option>
322
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
322
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
323 323
 										5.6.0
324 324
 									</option>
325
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
325
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
326 326
 										5.5.0
327 327
 									</option>
328
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
328
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
329 329
 										5.4.0
330 330
 									</option>
331
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
331
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
332 332
 										5.3.0
333 333
 									</option>
334
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
334
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
335 335
 										5.2.0
336 336
 									</option>
337
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
337
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
338 338
 										5.1.0
339 339
 									</option>
340
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
340
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
341 341
 										4.7.1 (CSS only)
342 342
 									</option>
343 343
 								</select>
@@ -345,51 +345,51 @@  discard block
 block discarded – undo
345 345
 						</tr>
346 346
 
347 347
 						<tr valign="top">
348
-							<th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
348
+							<th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
349 349
 							<td>
350 350
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
351 351
 									<option
352
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
352
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
353 353
 									<option
354
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
354
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
355 355
 									<option
356
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
356
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
357 357
 								</select>
358 358
 							</td>
359 359
 						</tr>
360 360
 
361 361
 						<tr valign="top">
362 362
 							<th scope="row"><label
363
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label></th>
363
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label></th>
364 364
 							<td>
365 365
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
366 366
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
367
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
368
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
367
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
368
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
369 369
 							</td>
370 370
 						</tr>
371 371
 
372 372
 						<tr valign="top">
373 373
 							<th scope="row"><label
374
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
374
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
375 375
 							</th>
376 376
 							<td>
377 377
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
378 378
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
379
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
379
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
380 380
 								       id="wpfas-js-pseudo"/>
381
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
381
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
382 382
 							</td>
383 383
 						</tr>
384 384
 
385 385
 						<tr valign="top">
386
-							<th scope="row"><label for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
386
+							<th scope="row"><label for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
387 387
 							<td>
388 388
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
389 389
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
390
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
390
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
391 391
 								       id="wpfas-dequeue"/>
392
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
392
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
393 393
 							</td>
394 394
 						</tr>
395 395
 
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 		 *
415 415
 		 * @return string Either a valid version number or an empty string.
416 416
 		 */
417
-		public function validate_version_number( $version ) {
417
+		public function validate_version_number($version) {
418 418
 
419
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
419
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
420 420
 				// valid
421 421
 			} else {
422
-				$version = '';// not validated
422
+				$version = ''; // not validated
423 423
 			}
424 424
 
425 425
 			return $version;
@@ -437,16 +437,16 @@  discard block
 block discarded – undo
437 437
 		public function get_latest_version($force_api = false) {
438 438
 			$latest_version = $this->latest;
439 439
 
440
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
440
+			$cache = get_transient('wp-font-awesome-settings-version');
441 441
 
442
-			if ( $cache === false || $force_api) { // its not set
442
+			if ($cache === false || $force_api) { // its not set
443 443
 				$api_ver = $this->get_latest_version_from_api();
444
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
444
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
445 445
 					$latest_version = $api_ver;
446
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
446
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
447 447
 				}
448
-			} elseif ( $this->validate_version_number( $cache ) ) {
449
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
448
+			} elseif ($this->validate_version_number($cache)) {
449
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
450 450
 					$latest_version = $cache;
451 451
 				}
452 452
 			}
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
 		 */
463 463
 		public function get_latest_version_from_api() {
464 464
 			$version  = "0";
465
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
466
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
467
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
468
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
465
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
466
+			if (!is_wp_error($response) && is_array($response)) {
467
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
468
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
469 469
 					$version = $api_response['tag_name'];
470 470
 				}
471 471
 			}
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 */
13 13
 
14 14
 // MUST have WordPress.
15
-if ( !defined( 'WPINC' ) ) {
16
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
15
+if (!defined('WPINC')) {
16
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
17 17
 }
18 18
 
19
-if ( !defined( 'WPINV_VERSION' ) ) {
20
-    define( 'WPINV_VERSION', '1.0.7' );
19
+if (!defined('WPINV_VERSION')) {
20
+    define('WPINV_VERSION', '1.0.7');
21 21
 }
22 22
 
23
-if ( !defined( 'WPINV_PLUGIN_FILE' ) ) {
24
-    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23
+if (!defined('WPINV_PLUGIN_FILE')) {
24
+    define('WPINV_PLUGIN_FILE', __FILE__);
25 25
 }
26 26
 
27
-require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php';
27
+require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php';
28 28
 
29 29
 function wpinv_run() {
30 30
     global $invoicing;
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,94 +13,94 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
18
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
18
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
19 19
     }
20 20
 
21 21
     public function admin_menu() {
22 22
         global $menu;
23 23
 
24
-        if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) {
24
+        if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) {
25 25
             return;
26 26
         }
27 27
 
28
-        $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' );
28
+        $capability = apply_filters('invoicing_capability', 'manage_invoicing');
29 29
 
30
-        if ( current_user_can( 'manage_options' ) ) {
31
-            $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
30
+        if (current_user_can('manage_options')) {
31
+            $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
32 32
         }
33 33
 
34
-        $wpi_invoice = get_post_type_object( 'wpi_invoice' );
34
+        $wpi_invoice = get_post_type_object('wpi_invoice');
35 35
 
36
-        add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
36
+        add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
37 37
 
38
-        add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' ));
38
+        add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page'));
39 39
     }
40 40
 
41 41
     function options_page() {
42
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
42
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
43 43
 
44
-        if ( $page !== 'wpinv-settings' ) {
44
+        if ($page !== 'wpinv-settings') {
45 45
             return;
46 46
         }
47 47
 
48 48
         $settings_tabs = wpinv_get_settings_tabs();
49 49
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
50
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
51
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
50
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
51
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
52 52
         $key           = 'main';
53 53
 
54
-        if ( is_array( $sections ) ) {
55
-            $key = key( $sections );
54
+        if (is_array($sections)) {
55
+            $key = key($sections);
56 56
         }
57 57
 
58
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
59
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
58
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
59
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
60 60
         ob_start();
61 61
         ?>
62 62
         <div class="wrap">
63 63
             <h1 class="nav-tab-wrapper">
64 64
                 <?php
65
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
66
-                    $tab_url = add_query_arg( array(
65
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
66
+                    $tab_url = add_query_arg(array(
67 67
                         'settings-updated' => false,
68 68
                         'tab' => $tab_id,
69
-                    ) );
69
+                    ));
70 70
 
71 71
                     // Remove the section from the tabs so we always end up at the main section
72
-                    $tab_url = remove_query_arg( 'section', $tab_url );
73
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
72
+                    $tab_url = remove_query_arg('section', $tab_url);
73
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
74 74
 
75 75
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
76 76
 
77
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
78
-                    echo esc_html( $tab_name );
77
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
78
+                    echo esc_html($tab_name);
79 79
                     echo '</a>';
80 80
                 }
81 81
                 ?>
82 82
             </h1>
83 83
             <?php
84
-            $number_of_sections = count( $sections );
84
+            $number_of_sections = count($sections);
85 85
             $number = 0;
86
-            if ( $number_of_sections > 1 ) {
86
+            if ($number_of_sections > 1) {
87 87
                 echo '<div><ul class="subsubsub">';
88
-                foreach( $sections as $section_id => $section_name ) {
88
+                foreach ($sections as $section_id => $section_name) {
89 89
                     echo '<li>';
90 90
                     $number++;
91
-                    $tab_url = add_query_arg( array(
91
+                    $tab_url = add_query_arg(array(
92 92
                         'settings-updated' => false,
93 93
                         'tab' => $active_tab,
94 94
                         'section' => $section_id
95
-                    ) );
96
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
95
+                    ));
96
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
97 97
                     $class = '';
98
-                    if ( $section == $section_id ) {
98
+                    if ($section == $section_id) {
99 99
                         $class = 'current';
100 100
                     }
101
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
101
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
102 102
 
103
-                    if ( $number != $number_of_sections ) {
103
+                    if ($number != $number_of_sections) {
104 104
                         echo ' | ';
105 105
                     }
106 106
                     echo '</li>';
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
                 <form method="post" action="options.php">
113 113
                     <table class="form-table">
114 114
                         <?php
115
-                        settings_fields( 'wpinv_settings' );
115
+                        settings_fields('wpinv_settings');
116 116
 
117
-                        if ( 'main' === $section ) {
118
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
117
+                        if ('main' === $section) {
118
+                            do_action('wpinv_settings_tab_top', $active_tab);
119 119
                         }
120 120
 
121
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
122
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
123
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
121
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
122
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
123
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
124 124
 
125 125
                         // For backwards compatibility
126
-                        if ( 'main' === $section ) {
127
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
126
+                        if ('main' === $section) {
127
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
128 128
                         }
129 129
                         ?>
130 130
                     </table>
@@ -138,52 +138,52 @@  discard block
 block discarded – undo
138 138
     }
139 139
 
140 140
     public function remove_admin_submenus() {
141
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
141
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
142 142
     }
143 143
 
144
-    public function add_nav_menu_meta_boxes(){
145
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
144
+    public function add_nav_menu_meta_boxes() {
145
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
146 146
     }
147 147
 
148
-    public function nav_menu_links(){
148
+    public function nav_menu_links() {
149 149
         $endpoints = $this->get_menu_items();
150 150
         ?>
151 151
         <div id="invoicing-endpoints" class="posttypediv">
152
-        <?php if(!empty($endpoints['pages'])){ ?>
152
+        <?php if (!empty($endpoints['pages'])) { ?>
153 153
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
154 154
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
155 155
                     <?php
156 156
                     $walker = new Walker_Nav_Menu_Checklist(array());
157
-                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
157
+                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object)array('walker' => $walker));
158 158
                     ?>
159 159
                 </ul>
160 160
             </div>
161 161
         <?php } ?>
162 162
         <p class="button-controls">
163 163
         <span class="list-controls">
164
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
164
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
165 165
         </span>
166 166
             <span class="add-to-menu">
167
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
167
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
168 168
             <span class="spinner"></span>
169 169
         </span>
170 170
         </p>
171 171
         <?php
172 172
     }
173 173
 
174
-    public function get_menu_items(){
174
+    public function get_menu_items() {
175 175
         $items = array();
176 176
 
177
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
178
-        if($wpinv_history_page_id > 0){
177
+        $wpinv_history_page_id = (int)wpinv_get_option('invoice_history_page');
178
+        if ($wpinv_history_page_id > 0) {
179 179
             $item = new stdClass();
180 180
             $item->object_id = $wpinv_history_page_id;
181 181
             $item->db_id = 0;
182
-            $item->object =  'page';
182
+            $item->object = 'page';
183 183
             $item->menu_item_parent = 0;
184 184
             $item->type = 'post_type';
185
-            $item->title = __('Invoice History Page','invoicing');
186
-            $item->url = get_permalink( $wpinv_history_page_id );
185
+            $item->title = __('Invoice History Page', 'invoicing');
186
+            $item->url = get_permalink($wpinv_history_page_id);
187 187
             $item->target = '';
188 188
             $item->attr_title = '';
189 189
             $item->classes = array('wpinv-menu-item');
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
             $items['pages'][] = $item;
193 193
         }
194 194
 
195
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
196
-        if($wpinv_sub_history_page_id > 0){
195
+        $wpinv_sub_history_page_id = (int)wpinv_get_option('invoice_subscription_page');
196
+        if ($wpinv_sub_history_page_id > 0) {
197 197
             $item = new stdClass();
198 198
             $item->object_id = $wpinv_sub_history_page_id;
199 199
             $item->db_id = 0;
200
-            $item->object =  'page';
200
+            $item->object = 'page';
201 201
             $item->menu_item_parent = 0;
202 202
             $item->type = 'post_type';
203
-            $item->title = __('Invoice Subscriptions Page','invoicing');
204
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
203
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
204
+            $item->url = get_permalink($wpinv_sub_history_page_id);
205 205
             $item->target = '';
206 206
             $item->attr_title = '';
207 207
             $item->classes = array('wpinv-menu-item');
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
             $items['pages'][] = $item;
211 211
         }
212 212
 
213
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
214
-        if($wpinv_checkout_page_id > 0){
213
+        $wpinv_checkout_page_id = (int)wpinv_get_option('checkout_page');
214
+        if ($wpinv_checkout_page_id > 0) {
215 215
             $item = new stdClass();
216 216
             $item->object_id = $wpinv_checkout_page_id;
217 217
             $item->db_id = 0;
218
-            $item->object =  'page';
218
+            $item->object = 'page';
219 219
             $item->menu_item_parent = 0;
220 220
             $item->type = 'post_type';
221
-            $item->title = __('Checkout Page','invoicing');
222
-            $item->url = get_permalink( $wpinv_checkout_page_id );
221
+            $item->title = __('Checkout Page', 'invoicing');
222
+            $item->url = get_permalink($wpinv_checkout_page_id);
223 223
             $item->target = '';
224 224
             $item->attr_title = '';
225 225
             $item->classes = array('wpinv-menu-item');
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
             $items['pages'][] = $item;
229 229
         }
230 230
 
231
-        $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' );
232
-        if($wpinv_tandc_page_id > 0){
231
+        $wpinv_tandc_page_id = (int)wpinv_get_option('tandc_page');
232
+        if ($wpinv_tandc_page_id > 0) {
233 233
             $item = new stdClass();
234 234
             $item->object_id = $wpinv_tandc_page_id;
235 235
             $item->db_id = 0;
236
-            $item->object =  'page';
236
+            $item->object = 'page';
237 237
             $item->menu_item_parent = 0;
238 238
             $item->type = 'post_type';
239
-            $item->title = __('Terms & Conditions','invoicing');
240
-            $item->url = get_permalink( $wpinv_tandc_page_id );
239
+            $item->title = __('Terms & Conditions', 'invoicing');
240
+            $item->url = get_permalink($wpinv_tandc_page_id);
241 241
             $item->target = '';
242 242
             $item->attr_title = '';
243 243
             $item->classes = array('wpinv-menu-item');
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
             $items['pages'][] = $item;
247 247
         }
248 248
 
249
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
250
-        if($wpinv_success_page_id > 0){
249
+        $wpinv_success_page_id = (int)wpinv_get_option('success_page');
250
+        if ($wpinv_success_page_id > 0) {
251 251
             $item = new stdClass();
252 252
             $item->object_id = $wpinv_success_page_id;
253 253
             $item->db_id = 0;
254
-            $item->object =  'page';
254
+            $item->object = 'page';
255 255
             $item->menu_item_parent = 0;
256 256
             $item->type = 'post_type';
257
-            $item->title = __('Success Page','invoicing');
258
-            $item->url = get_permalink( $wpinv_success_page_id );
257
+            $item->title = __('Success Page', 'invoicing');
258
+            $item->url = get_permalink($wpinv_success_page_id);
259 259
             $item->target = '';
260 260
             $item->attr_title = '';
261 261
             $item->classes = array('wpinv-menu-item');
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
             $items['pages'][] = $item;
265 265
         }
266 266
 
267
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
268
-        if($wpinv_failure_page_id > 0){
267
+        $wpinv_failure_page_id = (int)wpinv_get_option('failure_page');
268
+        if ($wpinv_failure_page_id > 0) {
269 269
             $item = new stdClass();
270 270
             $item->object_id = $wpinv_failure_page_id;
271 271
             $item->db_id = 0;
272
-            $item->object =  'page';
272
+            $item->object = 'page';
273 273
             $item->menu_item_parent = 0;
274 274
             $item->type = 'post_type';
275
-            $item->title = __('Failed Transaction Page','invoicing');
276
-            $item->url = get_permalink( $wpinv_failure_page_id );
275
+            $item->title = __('Failed Transaction Page', 'invoicing');
276
+            $item->url = get_permalink($wpinv_failure_page_id);
277 277
             $item->target = '';
278 278
             $item->attr_title = '';
279 279
             $item->classes = array('wpinv-menu-item');
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
             $items['pages'][] = $item;
283 283
         }
284 284
 
285
-        return apply_filters( 'wpinv_menu_items', $items );
285
+        return apply_filters('wpinv_menu_items', $items);
286 286
     }
287 287
 
288 288
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
     }
32 32
     
33 33
     public function define_constants() {
34
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
35
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
34
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
35
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
36 36
     }
37 37
     
38 38
     private function actions() {
39 39
         /* Internationalize the text strings used. */
40
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
40
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
41 41
         
42 42
         /* Perform actions on admin initialization. */
43
-        add_action( 'admin_init', array( &$this, 'admin_init') );
44
-        add_action( 'init', array( &$this, 'init' ), 3 );
45
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
43
+        add_action('admin_init', array(&$this, 'admin_init'));
44
+        add_action('init', array(&$this, 'init'), 3);
45
+        add_action('init', array('WPInv_Shortcodes', 'init'));
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53 53
         
54
-        if ( is_admin() ) {
55
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
56
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
54
+        if (is_admin()) {
55
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
56
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
57 57
         } else {
58
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
58
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
59 59
         }
60 60
         
61 61
         /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
          *
66 66
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
67 67
          */
68
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
68
+        do_action_ref_array('wpinv_actions', array(&$this));
69 69
 
70
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
70
+        add_action('admin_init', array(&$this, 'activation_redirect'));
71 71
     }
72 72
     
73 73
     public function plugins_loaded() {
74 74
         /* Internationalize the text strings used. */
75 75
         $this->load_textdomain();
76 76
 
77
-        do_action( 'wpinv_loaded' );
77
+        do_action('wpinv_loaded');
78 78
     }
79 79
     
80 80
     /**
@@ -82,211 +82,211 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @since 1.0
84 84
      */
85
-    public function load_textdomain( $locale = NULL ) {
86
-        if ( empty( $locale ) ) {
87
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
85
+    public function load_textdomain($locale = NULL) {
86
+        if (empty($locale)) {
87
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
88 88
         }
89 89
 
90
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
90
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
91 91
         
92
-        unload_textdomain( 'invoicing' );
93
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
94
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
92
+        unload_textdomain('invoicing');
93
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
94
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
95 95
         
96 96
         /**
97 97
          * Define language constants.
98 98
          */
99
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
99
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
100 100
     }
101 101
         
102 102
     public function includes() {
103 103
         global $wpinv_options;
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
106 106
         $wpinv_options = wpinv_get_settings();
107 107
         
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
131
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
132
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
137
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
131
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
132
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
137
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
140 140
 
141
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
142
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
141
+        if (!class_exists('WPInv_EUVat')) {
142
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
143 143
         }
144 144
         
145
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
146
-        if ( !empty( $gateways ) ) {
147
-            foreach ( $gateways as $gateway ) {
148
-                if ( $gateway == 'manual' ) {
145
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
146
+        if (!empty($gateways)) {
147
+            foreach ($gateways as $gateway) {
148
+                if ($gateway == 'manual') {
149 149
                     continue;
150 150
                 }
151 151
                 
152 152
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
153 153
                 
154
-                if ( file_exists( $gateway_file ) ) {
155
-                    require_once( $gateway_file );
154
+                if (file_exists($gateway_file)) {
155
+                    require_once($gateway_file);
156 156
                 }
157 157
             }
158 158
         }
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
160 160
         
161
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
162
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
163
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
164
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
161
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
162
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
163
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
164
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
165 165
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
166
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
167
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
168
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
169
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
170
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
171
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
172
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
166
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
167
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
168
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
169
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
170
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
171
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
172
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
173 173
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
174 174
             // load the user class only on the users.php page
175 175
             global $pagenow;
176
-            if($pagenow=='users.php'){
176
+            if ($pagenow == 'users.php') {
177 177
                 new WPInv_Admin_Users();
178 178
             }
179 179
         }
180 180
         
181 181
         // include css inliner
182
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
183
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
182
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
183
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
184 184
         }
185 185
         
186
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
186
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
187 187
     }
188 188
     
189 189
     public function init() {
190 190
     }
191 191
     
192 192
     public function admin_init() {
193
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
193
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
194 194
         }
195 195
         
196
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
196
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
197 197
     }
198 198
 
199 199
     public function activation_redirect() {
200 200
         // Bail if no activation redirect
201
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
201
+        if (!get_transient('_wpinv_activation_redirect')) {
202 202
             return;
203 203
         }
204 204
 
205 205
         // Delete the redirect transient
206
-        delete_transient( '_wpinv_activation_redirect' );
206
+        delete_transient('_wpinv_activation_redirect');
207 207
 
208 208
         // Bail if activating from network, or bulk
209
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
209
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
210 210
             return;
211 211
         }
212 212
 
213
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
213
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
214 214
         exit;
215 215
     }
216 216
     
217 217
     public function enqueue_scripts() {
218
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
218
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
219 219
         
220
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
221
-        wp_enqueue_style( 'wpinv_front_style' );
220
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
221
+        wp_enqueue_style('wpinv_front_style');
222 222
                
223 223
         // Register scripts
224
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
225
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
224
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
225
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery'), WPINV_VERSION);
226 226
 
227 227
         $localize                         = array();
228
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
229
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
228
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
229
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
230 230
         $localize['currency_symbol']      = wpinv_currency_symbol();
231 231
         $localize['currency_pos']         = wpinv_currency_position();
232 232
         $localize['thousand_sep']         = wpinv_thousands_separator();
233 233
         $localize['decimal_sep']          = wpinv_decimal_separator();
234 234
         $localize['decimals']             = wpinv_decimals();
235
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
235
+        $localize['txtComplete']          = __('Complete', 'invoicing');
236 236
         
237
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
237
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
238 238
         
239
-        wp_enqueue_script( 'jquery-blockui' );
239
+        wp_enqueue_script('jquery-blockui');
240 240
         $autofill_api = wpinv_get_option('address_autofill_api');
241 241
         $autofill_active = wpinv_get_option('address_autofill_active');
242
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
243
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
244
-                wp_dequeue_script( 'google-maps-api' );
242
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
243
+            if (wp_script_is('google-maps-api', 'enqueued')) {
244
+                wp_dequeue_script('google-maps-api');
245 245
             }
246
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
247
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
246
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
247
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
248 248
         }
249
-        wp_enqueue_script( 'wpinv-front-script' );
250
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
249
+        wp_enqueue_script('wpinv-front-script');
250
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
251 251
     }
252 252
 
253 253
     public function admin_enqueue_scripts() {
254 254
         global $post, $pagenow;
255 255
         
256 256
         $post_type  = wpinv_admin_post_type();
257
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
258
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
257
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
258
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
259 259
 
260 260
         $jquery_ui_css = false;
261
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
261
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
262 262
             $jquery_ui_css = true;
263
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
263
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
264 264
             $jquery_ui_css = true;
265 265
         }
266
-        if ( $jquery_ui_css ) {
267
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
268
-            wp_enqueue_style( 'jquery-ui-css' );
266
+        if ($jquery_ui_css) {
267
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
268
+            wp_enqueue_style('jquery-ui-css');
269 269
         }
270 270
 
271
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
272
-        wp_enqueue_style( 'wpinv_meta_box_style' );
271
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
272
+        wp_enqueue_style('wpinv_meta_box_style');
273 273
         
274
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
275
-        wp_enqueue_style( 'wpinv_admin_style' );
274
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
275
+        wp_enqueue_style('wpinv_admin_style');
276 276
 
277
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
278
-        if ( $page == 'wpinv-subscriptions' ) {
279
-            wp_enqueue_script( 'jquery-ui-datepicker' );
277
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
278
+        if ($page == 'wpinv-subscriptions') {
279
+            wp_enqueue_script('jquery-ui-datepicker');
280 280
         }
281 281
         
282
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
283
-            wp_enqueue_script( 'jquery-ui-datepicker' );
282
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
283
+            wp_enqueue_script('jquery-ui-datepicker');
284 284
         }
285 285
 
286
-        wp_enqueue_style( 'wp-color-picker' );
287
-        wp_enqueue_script( 'wp-color-picker' );
286
+        wp_enqueue_style('wp-color-picker');
287
+        wp_enqueue_script('wp-color-picker');
288 288
         
289
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
289
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
290 290
 
291 291
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
292 292
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
             }
298 298
         }
299 299
 
300
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
301
-        wp_enqueue_script( 'wpinv-admin-script' );
300
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
301
+        wp_enqueue_script('wpinv-admin-script');
302 302
         
303 303
         $localize                               = array();
304
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
305
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
306
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
307
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
308
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
309
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
310
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
304
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
305
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
306
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
307
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
308
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
309
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
310
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
311 311
         $localize['tax']                        = wpinv_tax_amount();
312 312
         $localize['discount']                   = wpinv_discount_amount();
313 313
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -315,69 +315,69 @@  discard block
 block discarded – undo
315 315
         $localize['thousand_sep']               = wpinv_thousands_separator();
316 316
         $localize['decimal_sep']                = wpinv_decimal_separator();
317 317
         $localize['decimals']                   = wpinv_decimals();
318
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
319
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
320
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
321
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
322
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
323
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
324
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
325
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
326
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
327
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
328
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
329
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
330
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
331
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
318
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
319
+        $localize['status_publish']             = wpinv_status_nicename('publish');
320
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
321
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
322
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
323
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
324
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
325
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
326
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
327
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
328
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
329
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
330
+        $localize['action_edit']                = __('Edit', 'invoicing');
331
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
332 332
 
333
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
333
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
334 334
 
335
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
335
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
336 336
 
337
-        if ( $page == 'wpinv-subscriptions' ) {
338
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
339
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
337
+        if ($page == 'wpinv-subscriptions') {
338
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION);
339
+            wp_enqueue_script('wpinv-sub-admin-script');
340 340
         }
341 341
     }
342 342
     
343
-    public function admin_body_class( $classes ) {
343
+    public function admin_body_class($classes) {
344 344
         global $pagenow, $post, $current_screen;
345 345
         
346
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
346
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
347 347
             $classes .= ' wpinv-cpt';
348 348
         }
349 349
         
350
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
350
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
351 351
 
352
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
353
-        if ( $add_class ) {
354
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
352
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
353
+        if ($add_class) {
354
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
355 355
         }
356 356
         
357 357
         $settings_class = array();
358
-        if ( $page == 'wpinv-settings' ) {
359
-            if ( !empty( $_REQUEST['tab'] ) ) {
360
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
358
+        if ($page == 'wpinv-settings') {
359
+            if (!empty($_REQUEST['tab'])) {
360
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
361 361
             }
362 362
             
363
-            if ( !empty( $_REQUEST['section'] ) ) {
364
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
363
+            if (!empty($_REQUEST['section'])) {
364
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
365 365
             }
366 366
             
367
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
367
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
368 368
         }
369 369
         
370
-        if ( !empty( $settings_class ) ) {
371
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
370
+        if (!empty($settings_class)) {
371
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
372 372
         }
373 373
         
374 374
         $post_type = wpinv_admin_post_type();
375 375
 
376
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
376
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
377 377
             return $classes .= ' wpinv';
378 378
         }
379 379
         
380
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
380
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
381 381
             $classes .= ' wpi-editable-n';
382 382
         }
383 383
 
@@ -389,20 +389,20 @@  discard block
 block discarded – undo
389 389
     }
390 390
     
391 391
     public function wpinv_actions() {
392
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
393
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
392
+        if (isset($_REQUEST['wpi_action'])) {
393
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
394 394
         }
395 395
     }
396 396
     
397
-    public function pre_get_posts( $wp_query ) {
398
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
399
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
397
+    public function pre_get_posts($wp_query) {
398
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
399
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
400 400
         }
401 401
         
402 402
         return $wp_query;
403 403
     }
404 404
     
405 405
     public function bp_invoicing_init() {
406
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
406
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
407 407
     }
408 408
 }
409 409
\ No newline at end of file
Please login to merge, or discard this patch.