@@ -10,294 +10,294 @@ discard block |
||
10 | 10 | // Ensure the class is only loaded once. |
11 | 11 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
12 | 12 | |
13 | - /** |
|
14 | - * |
|
15 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
16 | - * |
|
17 | - * View hello-world.php for example usage |
|
18 | - * |
|
19 | - * @since 1.0.0 |
|
20 | - * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
21 | - * @since 2.0.0 shortcode, widget and blocks moved into separate files - CHANGED |
|
22 | - * @version 2.0.0 |
|
23 | - */ |
|
24 | - abstract class WP_Super_Duper { |
|
25 | - |
|
26 | - public $version = "2.0.1"; |
|
27 | - public $font_awesome_icon_version = "5.11.2"; |
|
28 | - public $block_code; |
|
29 | - public $options; |
|
30 | - public $base_id; |
|
31 | - public $number; |
|
32 | - public $settings_hash; |
|
33 | - public $arguments = array(); |
|
34 | - public $instance = array(); |
|
35 | - |
|
36 | - // prevent SDv1 errors if register_widget() function used |
|
37 | - public $id_base; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var array Contains an array of output types instances. |
|
41 | - */ |
|
42 | - public $output_types = array(); |
|
43 | - |
|
44 | - /** |
|
45 | - * The relative url to the current folder. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $url = ''; |
|
50 | - |
|
51 | - /** |
|
52 | - * Take the array options and use them to build. |
|
53 | - */ |
|
54 | - public function __construct( $options ) { |
|
55 | - global $sd_widgets; |
|
56 | - |
|
57 | - $sd_widgets[ $options['base_id'] ] = array( |
|
58 | - 'name' => $options['name'], |
|
59 | - 'class_name' => $options['class_name'] |
|
60 | - ); |
|
61 | - $this->base_id = $options['base_id']; |
|
62 | - |
|
63 | - // Lets filter the options before we do anything. |
|
64 | - $options = apply_filters( 'wp_super_duper_options', $options, $this ); |
|
65 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options, $this ); |
|
66 | - $options = $this->add_name_from_key( $options ); |
|
67 | - |
|
68 | - // Set args. |
|
69 | - $this->options = $options; |
|
70 | - $this->base_id = $options['base_id']; |
|
71 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
72 | - |
|
73 | - // Load output types. |
|
74 | - $this->load_output_types(); |
|
75 | - |
|
76 | - // add generator text to admin head |
|
77 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
78 | - |
|
79 | - add_action( 'admin_init', array( __CLASS__, 'load_widgets_setting' ) ); |
|
80 | - |
|
81 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
82 | - |
|
83 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
84 | - |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Set the name from the argument key. |
|
89 | - * |
|
90 | - * @param array $options |
|
91 | - * @param bool $arguments |
|
92 | - * |
|
93 | - * @return mixed |
|
94 | - */ |
|
95 | - protected function add_name_from_key( $options, $arguments = false ) { |
|
96 | - if ( ! empty( $options['arguments'] ) ) { |
|
97 | - foreach ( $options['arguments'] as $key => $val ) { |
|
98 | - $options['arguments'][ $key ]['name'] = $key; |
|
99 | - } |
|
100 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
101 | - foreach ( $options as $key => $val ) { |
|
102 | - $options[ $key ]['name'] = $key; |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - return $options; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Output the version in the admin header. |
|
111 | - */ |
|
112 | - public function load_output_types() { |
|
113 | - |
|
114 | - $allowed_types = $this->get_output_types(); |
|
115 | - $output_types = array( 'block', 'shortcode', 'widget' ); |
|
116 | - |
|
117 | - // Check if this is being overidden by the widget. |
|
118 | - $args = $this->get_arguments(); |
|
119 | - if ( isset( $args['output_types'] ) && is_array( $args['output_types'] ) ) { |
|
120 | - $output_types = $args['output_types'] ; |
|
121 | - } |
|
122 | - |
|
123 | - if ( isset( $this->options['output_types'] ) && is_array( $this->options['output_types'] ) ) { |
|
124 | - $output_types = $this->options['output_types'] ; |
|
125 | - } |
|
126 | - |
|
127 | - // Load each output type. |
|
128 | - foreach ( $output_types as $output_type ) { |
|
129 | - |
|
130 | - // Ensure this is an allowed type. |
|
131 | - if ( ! isset( $allowed_types[ $output_type ] ) ) { |
|
132 | - continue; |
|
133 | - } |
|
134 | - |
|
135 | - // If the class does not exist, try loading it. |
|
136 | - if ( ! class_exists( $allowed_types[ $output_type ] ) ) { |
|
137 | - |
|
138 | - if ( file_exists( plugin_dir_path( __FILE__ ) . "type/$output_type.php" ) ) { |
|
139 | - require_once( plugin_dir_path( __FILE__ ) . "type/$output_type.php" ); |
|
140 | - } else { |
|
141 | - continue; |
|
142 | - } |
|
143 | - |
|
144 | - } |
|
145 | - |
|
146 | - $output_class = $allowed_types[ $output_type ]; |
|
147 | - $this->output_types[ $output_type ] = new $output_class( $this ); |
|
148 | - } |
|
149 | - |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Retrieves an array of available SD types. |
|
154 | - * |
|
155 | - * @return array |
|
156 | - */ |
|
157 | - protected function get_output_types() { |
|
158 | - |
|
159 | - // Output type id and class. |
|
160 | - $types = array( |
|
161 | - 'block' => 'WP_Super_Duper_Block', |
|
162 | - 'shortcode' => 'WP_Super_Duper_Shortcode', |
|
163 | - 'widget' => 'WP_Super_Duper_Widget', |
|
164 | - ); |
|
165 | - |
|
166 | - // Maybe disable widgets. |
|
167 | - $disable_widget = get_option( 'sd_load_widgets', 'auto' ); |
|
168 | - |
|
169 | - if ( 'auto' === $disable_widget ) { |
|
170 | - if ( !$this->widgets_required() ) { |
|
171 | - unset( $types['widget'] ); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - if ( 'no' === $disable_widget ) { |
|
176 | - unset( $types['widget'] ); |
|
177 | - } |
|
178 | - |
|
179 | - return apply_filters( 'super_duper_types', $types, $this ); |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * Check if we are required to load widgets. |
|
184 | - * |
|
185 | - * @return mixed|void |
|
186 | - */ |
|
187 | - protected function widgets_required(){ |
|
188 | - global $wp_version; |
|
189 | - |
|
190 | - $required = false; |
|
191 | - |
|
192 | - |
|
193 | - // check wp version |
|
194 | - if( version_compare( $wp_version, '5.8', '<' ) ){ |
|
195 | - $required = true; |
|
196 | - } |
|
197 | - |
|
198 | - // Page builders that require widgets |
|
199 | - if( |
|
200 | - !$required && ( |
|
201 | - defined( 'ELEMENTOR_VERSION' ) // elementor |
|
202 | - || class_exists( 'Fusion_Element' ) // Fusion Builder (avada) |
|
203 | - || class_exists( 'SiteOrigin_Panels' ) // SiteOrigin Page builder |
|
204 | - || defined( 'WPB_VC_VERSION' ) // WPBakery page builder |
|
205 | - || defined( 'CT_VERSION' ) // Oxygen Builder |
|
206 | - || defined( 'FL_BUILDER_VERSION' ) // Beaver Builder |
|
207 | - || defined( 'FL_THEME_BUILDER_VERSION' ) // Beaver Themer |
|
208 | - ) |
|
209 | - ){ |
|
210 | - $required = true; |
|
211 | - } |
|
212 | - |
|
213 | - // Theme has active widgets |
|
214 | - if( !$required && !empty( $this->has_active_widgets() ) ){ |
|
215 | - $required = true; |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - return apply_filters( 'sd_widgets_required' , $required ); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Check if the current site has any active old style widgets. |
|
224 | - * |
|
225 | - * @return bool |
|
226 | - */ |
|
227 | - protected function has_active_widgets(){ |
|
228 | - global $sd_has_active_widgets; |
|
229 | - |
|
230 | - // have we already done this? |
|
231 | - if(!is_null($sd_has_active_widgets)){ |
|
232 | - return $sd_has_active_widgets; |
|
233 | - } |
|
234 | - |
|
235 | - $result = false; |
|
236 | - $sidebars_widgets = get_option('sidebars_widgets'); |
|
237 | - |
|
238 | - if(is_array($sidebars_widgets)){ |
|
239 | - |
|
240 | - foreach ($sidebars_widgets as $key => $value) { |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - if( $key != 'wp_inactive_widgets' ) { |
|
245 | - |
|
246 | - if(!empty($value) && is_array($value)){ |
|
247 | - foreach($value as $widget){ |
|
248 | - if($widget && substr( $widget, 0, 6 ) !== "block-"){ |
|
249 | - $result = true; |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - |
|
258 | - $sd_has_active_widgets = $result; |
|
259 | - |
|
260 | - return $result; |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * Get arguments in super duper. |
|
265 | - * |
|
266 | - * @since 1.0.0 |
|
267 | - * |
|
268 | - * @return array Get arguments. |
|
269 | - */ |
|
270 | - public function get_arguments() { |
|
271 | - if ( empty( $this->arguments ) ) { |
|
272 | - $this->arguments = $this->set_arguments(); |
|
273 | - } |
|
274 | - |
|
275 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
276 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
277 | - |
|
278 | - return $this->arguments; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Set arguments in super duper. |
|
283 | - * |
|
284 | - * @since 1.0.0 |
|
285 | - * |
|
286 | - * @return array Set arguments. |
|
287 | - */ |
|
288 | - public function set_arguments() { |
|
289 | - return $this->arguments; |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Makes SD work with the siteOrigin page builder. |
|
294 | - * |
|
295 | - * @since 1.0.6 |
|
296 | - * @return mixed |
|
297 | - */ |
|
298 | - public static function siteorigin_js() { |
|
299 | - ob_start(); |
|
300 | - ?> |
|
13 | + /** |
|
14 | + * |
|
15 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
16 | + * |
|
17 | + * View hello-world.php for example usage |
|
18 | + * |
|
19 | + * @since 1.0.0 |
|
20 | + * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
21 | + * @since 2.0.0 shortcode, widget and blocks moved into separate files - CHANGED |
|
22 | + * @version 2.0.0 |
|
23 | + */ |
|
24 | + abstract class WP_Super_Duper { |
|
25 | + |
|
26 | + public $version = "2.0.1"; |
|
27 | + public $font_awesome_icon_version = "5.11.2"; |
|
28 | + public $block_code; |
|
29 | + public $options; |
|
30 | + public $base_id; |
|
31 | + public $number; |
|
32 | + public $settings_hash; |
|
33 | + public $arguments = array(); |
|
34 | + public $instance = array(); |
|
35 | + |
|
36 | + // prevent SDv1 errors if register_widget() function used |
|
37 | + public $id_base; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var array Contains an array of output types instances. |
|
41 | + */ |
|
42 | + public $output_types = array(); |
|
43 | + |
|
44 | + /** |
|
45 | + * The relative url to the current folder. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $url = ''; |
|
50 | + |
|
51 | + /** |
|
52 | + * Take the array options and use them to build. |
|
53 | + */ |
|
54 | + public function __construct( $options ) { |
|
55 | + global $sd_widgets; |
|
56 | + |
|
57 | + $sd_widgets[ $options['base_id'] ] = array( |
|
58 | + 'name' => $options['name'], |
|
59 | + 'class_name' => $options['class_name'] |
|
60 | + ); |
|
61 | + $this->base_id = $options['base_id']; |
|
62 | + |
|
63 | + // Lets filter the options before we do anything. |
|
64 | + $options = apply_filters( 'wp_super_duper_options', $options, $this ); |
|
65 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options, $this ); |
|
66 | + $options = $this->add_name_from_key( $options ); |
|
67 | + |
|
68 | + // Set args. |
|
69 | + $this->options = $options; |
|
70 | + $this->base_id = $options['base_id']; |
|
71 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
72 | + |
|
73 | + // Load output types. |
|
74 | + $this->load_output_types(); |
|
75 | + |
|
76 | + // add generator text to admin head |
|
77 | + add_action( 'admin_head', array( $this, 'generator' ) ); |
|
78 | + |
|
79 | + add_action( 'admin_init', array( __CLASS__, 'load_widgets_setting' ) ); |
|
80 | + |
|
81 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
82 | + |
|
83 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
84 | + |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Set the name from the argument key. |
|
89 | + * |
|
90 | + * @param array $options |
|
91 | + * @param bool $arguments |
|
92 | + * |
|
93 | + * @return mixed |
|
94 | + */ |
|
95 | + protected function add_name_from_key( $options, $arguments = false ) { |
|
96 | + if ( ! empty( $options['arguments'] ) ) { |
|
97 | + foreach ( $options['arguments'] as $key => $val ) { |
|
98 | + $options['arguments'][ $key ]['name'] = $key; |
|
99 | + } |
|
100 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
101 | + foreach ( $options as $key => $val ) { |
|
102 | + $options[ $key ]['name'] = $key; |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + return $options; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Output the version in the admin header. |
|
111 | + */ |
|
112 | + public function load_output_types() { |
|
113 | + |
|
114 | + $allowed_types = $this->get_output_types(); |
|
115 | + $output_types = array( 'block', 'shortcode', 'widget' ); |
|
116 | + |
|
117 | + // Check if this is being overidden by the widget. |
|
118 | + $args = $this->get_arguments(); |
|
119 | + if ( isset( $args['output_types'] ) && is_array( $args['output_types'] ) ) { |
|
120 | + $output_types = $args['output_types'] ; |
|
121 | + } |
|
122 | + |
|
123 | + if ( isset( $this->options['output_types'] ) && is_array( $this->options['output_types'] ) ) { |
|
124 | + $output_types = $this->options['output_types'] ; |
|
125 | + } |
|
126 | + |
|
127 | + // Load each output type. |
|
128 | + foreach ( $output_types as $output_type ) { |
|
129 | + |
|
130 | + // Ensure this is an allowed type. |
|
131 | + if ( ! isset( $allowed_types[ $output_type ] ) ) { |
|
132 | + continue; |
|
133 | + } |
|
134 | + |
|
135 | + // If the class does not exist, try loading it. |
|
136 | + if ( ! class_exists( $allowed_types[ $output_type ] ) ) { |
|
137 | + |
|
138 | + if ( file_exists( plugin_dir_path( __FILE__ ) . "type/$output_type.php" ) ) { |
|
139 | + require_once( plugin_dir_path( __FILE__ ) . "type/$output_type.php" ); |
|
140 | + } else { |
|
141 | + continue; |
|
142 | + } |
|
143 | + |
|
144 | + } |
|
145 | + |
|
146 | + $output_class = $allowed_types[ $output_type ]; |
|
147 | + $this->output_types[ $output_type ] = new $output_class( $this ); |
|
148 | + } |
|
149 | + |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Retrieves an array of available SD types. |
|
154 | + * |
|
155 | + * @return array |
|
156 | + */ |
|
157 | + protected function get_output_types() { |
|
158 | + |
|
159 | + // Output type id and class. |
|
160 | + $types = array( |
|
161 | + 'block' => 'WP_Super_Duper_Block', |
|
162 | + 'shortcode' => 'WP_Super_Duper_Shortcode', |
|
163 | + 'widget' => 'WP_Super_Duper_Widget', |
|
164 | + ); |
|
165 | + |
|
166 | + // Maybe disable widgets. |
|
167 | + $disable_widget = get_option( 'sd_load_widgets', 'auto' ); |
|
168 | + |
|
169 | + if ( 'auto' === $disable_widget ) { |
|
170 | + if ( !$this->widgets_required() ) { |
|
171 | + unset( $types['widget'] ); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + if ( 'no' === $disable_widget ) { |
|
176 | + unset( $types['widget'] ); |
|
177 | + } |
|
178 | + |
|
179 | + return apply_filters( 'super_duper_types', $types, $this ); |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * Check if we are required to load widgets. |
|
184 | + * |
|
185 | + * @return mixed|void |
|
186 | + */ |
|
187 | + protected function widgets_required(){ |
|
188 | + global $wp_version; |
|
189 | + |
|
190 | + $required = false; |
|
191 | + |
|
192 | + |
|
193 | + // check wp version |
|
194 | + if( version_compare( $wp_version, '5.8', '<' ) ){ |
|
195 | + $required = true; |
|
196 | + } |
|
197 | + |
|
198 | + // Page builders that require widgets |
|
199 | + if( |
|
200 | + !$required && ( |
|
201 | + defined( 'ELEMENTOR_VERSION' ) // elementor |
|
202 | + || class_exists( 'Fusion_Element' ) // Fusion Builder (avada) |
|
203 | + || class_exists( 'SiteOrigin_Panels' ) // SiteOrigin Page builder |
|
204 | + || defined( 'WPB_VC_VERSION' ) // WPBakery page builder |
|
205 | + || defined( 'CT_VERSION' ) // Oxygen Builder |
|
206 | + || defined( 'FL_BUILDER_VERSION' ) // Beaver Builder |
|
207 | + || defined( 'FL_THEME_BUILDER_VERSION' ) // Beaver Themer |
|
208 | + ) |
|
209 | + ){ |
|
210 | + $required = true; |
|
211 | + } |
|
212 | + |
|
213 | + // Theme has active widgets |
|
214 | + if( !$required && !empty( $this->has_active_widgets() ) ){ |
|
215 | + $required = true; |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + return apply_filters( 'sd_widgets_required' , $required ); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Check if the current site has any active old style widgets. |
|
224 | + * |
|
225 | + * @return bool |
|
226 | + */ |
|
227 | + protected function has_active_widgets(){ |
|
228 | + global $sd_has_active_widgets; |
|
229 | + |
|
230 | + // have we already done this? |
|
231 | + if(!is_null($sd_has_active_widgets)){ |
|
232 | + return $sd_has_active_widgets; |
|
233 | + } |
|
234 | + |
|
235 | + $result = false; |
|
236 | + $sidebars_widgets = get_option('sidebars_widgets'); |
|
237 | + |
|
238 | + if(is_array($sidebars_widgets)){ |
|
239 | + |
|
240 | + foreach ($sidebars_widgets as $key => $value) { |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + if( $key != 'wp_inactive_widgets' ) { |
|
245 | + |
|
246 | + if(!empty($value) && is_array($value)){ |
|
247 | + foreach($value as $widget){ |
|
248 | + if($widget && substr( $widget, 0, 6 ) !== "block-"){ |
|
249 | + $result = true; |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + |
|
258 | + $sd_has_active_widgets = $result; |
|
259 | + |
|
260 | + return $result; |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * Get arguments in super duper. |
|
265 | + * |
|
266 | + * @since 1.0.0 |
|
267 | + * |
|
268 | + * @return array Get arguments. |
|
269 | + */ |
|
270 | + public function get_arguments() { |
|
271 | + if ( empty( $this->arguments ) ) { |
|
272 | + $this->arguments = $this->set_arguments(); |
|
273 | + } |
|
274 | + |
|
275 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
276 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
277 | + |
|
278 | + return $this->arguments; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Set arguments in super duper. |
|
283 | + * |
|
284 | + * @since 1.0.0 |
|
285 | + * |
|
286 | + * @return array Set arguments. |
|
287 | + */ |
|
288 | + public function set_arguments() { |
|
289 | + return $this->arguments; |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Makes SD work with the siteOrigin page builder. |
|
294 | + * |
|
295 | + * @since 1.0.6 |
|
296 | + * @return mixed |
|
297 | + */ |
|
298 | + public static function siteorigin_js() { |
|
299 | + ob_start(); |
|
300 | + ?> |
|
301 | 301 | <script> |
302 | 302 | /** |
303 | 303 | * Check a form to see what items should be shown or hidden. |
@@ -375,50 +375,50 @@ discard block |
||
375 | 375 | }); |
376 | 376 | </script> |
377 | 377 | <?php |
378 | - $output = ob_get_clean(); |
|
378 | + $output = ob_get_clean(); |
|
379 | 379 | |
380 | - /* |
|
380 | + /* |
|
381 | 381 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
382 | 382 | */ |
383 | - return str_replace( array( |
|
384 | - '<script>', |
|
385 | - '</script>' |
|
386 | - ), '', $output ); |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * A function to ge the shortcode builder picker html. |
|
391 | - * |
|
392 | - * @param string $editor_id |
|
393 | - * |
|
394 | - * @return string |
|
395 | - */ |
|
396 | - public static function get_picker( $editor_id = '' ) { |
|
397 | - |
|
398 | - ob_start(); |
|
399 | - if ( isset( $_POST['editor_id'] ) ) { |
|
400 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
401 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
402 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
403 | - } |
|
404 | - |
|
405 | - global $sd_widgets; |
|
406 | - ?> |
|
383 | + return str_replace( array( |
|
384 | + '<script>', |
|
385 | + '</script>' |
|
386 | + ), '', $output ); |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * A function to ge the shortcode builder picker html. |
|
391 | + * |
|
392 | + * @param string $editor_id |
|
393 | + * |
|
394 | + * @return string |
|
395 | + */ |
|
396 | + public static function get_picker( $editor_id = '' ) { |
|
397 | + |
|
398 | + ob_start(); |
|
399 | + if ( isset( $_POST['editor_id'] ) ) { |
|
400 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
401 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
402 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
403 | + } |
|
404 | + |
|
405 | + global $sd_widgets; |
|
406 | + ?> |
|
407 | 407 | |
408 | 408 | <div class="sd-shortcode-left-wrap"> |
409 | 409 | <?php |
410 | - ksort( $sd_widgets ); |
|
411 | - // print_r($sd_widgets);exit; |
|
412 | - if ( ! empty( $sd_widgets ) ) { |
|
413 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
414 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
415 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
416 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
417 | - } |
|
418 | - echo "</select>"; |
|
419 | - |
|
420 | - } |
|
421 | - ?> |
|
410 | + ksort( $sd_widgets ); |
|
411 | + // print_r($sd_widgets);exit; |
|
412 | + if ( ! empty( $sd_widgets ) ) { |
|
413 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
414 | + echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
415 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
416 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
417 | + } |
|
418 | + echo "</select>"; |
|
419 | + |
|
420 | + } |
|
421 | + ?> |
|
422 | 422 | <div class="sd-shortcode-settings"></div> |
423 | 423 | |
424 | 424 | </div> |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | <?php if ( $editor_id != '' ) { ?> |
430 | 430 | <button class="button sd-insert-shortcode-button" |
431 | 431 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
432 | - echo "'" . $editor_id . "'"; |
|
433 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
432 | + echo "'" . $editor_id . "'"; |
|
433 | + } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
434 | 434 | <?php } ?> |
435 | 435 | <button class="button" |
436 | 436 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -438,44 +438,44 @@ discard block |
||
438 | 438 | </div> |
439 | 439 | <?php |
440 | 440 | |
441 | - $html = ob_get_clean(); |
|
441 | + $html = ob_get_clean(); |
|
442 | 442 | |
443 | - if ( wp_doing_ajax() ) { |
|
444 | - echo $html; |
|
445 | - $should_die = true; |
|
443 | + if ( wp_doing_ajax() ) { |
|
444 | + echo $html; |
|
445 | + $should_die = true; |
|
446 | 446 | |
447 | - // some builder get the editor via ajax so we should not die on those occasions |
|
448 | - $dont_die = array( |
|
449 | - 'parent_tag',// WP Bakery |
|
450 | - 'avia_request' // enfold |
|
451 | - ); |
|
447 | + // some builder get the editor via ajax so we should not die on those occasions |
|
448 | + $dont_die = array( |
|
449 | + 'parent_tag',// WP Bakery |
|
450 | + 'avia_request' // enfold |
|
451 | + ); |
|
452 | 452 | |
453 | - foreach ( $dont_die as $request ) { |
|
454 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
455 | - $should_die = false; |
|
456 | - } |
|
457 | - } |
|
453 | + foreach ( $dont_die as $request ) { |
|
454 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
455 | + $should_die = false; |
|
456 | + } |
|
457 | + } |
|
458 | 458 | |
459 | - if ( $should_die ) { |
|
460 | - wp_die(); |
|
461 | - } |
|
459 | + if ( $should_die ) { |
|
460 | + wp_die(); |
|
461 | + } |
|
462 | 462 | |
463 | - } else { |
|
464 | - return $html; |
|
465 | - } |
|
463 | + } else { |
|
464 | + return $html; |
|
465 | + } |
|
466 | 466 | |
467 | - return ''; |
|
467 | + return ''; |
|
468 | 468 | |
469 | - } |
|
469 | + } |
|
470 | 470 | |
471 | - /** |
|
472 | - * Returns the JS used to render the widget/shortcode settings form. |
|
473 | - * |
|
474 | - * @return string |
|
475 | - */ |
|
476 | - public static function widget_js() { |
|
477 | - ob_start(); |
|
478 | - ?> |
|
471 | + /** |
|
472 | + * Returns the JS used to render the widget/shortcode settings form. |
|
473 | + * |
|
474 | + * @return string |
|
475 | + */ |
|
476 | + public static function widget_js() { |
|
477 | + ob_start(); |
|
478 | + ?> |
|
479 | 479 | <script> |
480 | 480 | |
481 | 481 | /** |
@@ -633,28 +633,28 @@ discard block |
||
633 | 633 | </script> |
634 | 634 | |
635 | 635 | <?php |
636 | - $output = ob_get_clean(); |
|
636 | + $output = ob_get_clean(); |
|
637 | 637 | |
638 | - /* |
|
638 | + /* |
|
639 | 639 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
640 | 640 | */ |
641 | 641 | |
642 | - return str_replace( array( |
|
643 | - '<script>', |
|
644 | - '</script>' |
|
645 | - ), '', $output ); |
|
646 | - } |
|
647 | - |
|
648 | - /** |
|
649 | - * Returns the CSS used to render the widget/shortcode settings form. |
|
650 | - * |
|
651 | - * @param bool $advanced If we should include advanced CSS. |
|
652 | - * |
|
653 | - * @return mixed |
|
654 | - */ |
|
655 | - public static function widget_css( $advanced = true ) { |
|
656 | - ob_start(); |
|
657 | - ?> |
|
642 | + return str_replace( array( |
|
643 | + '<script>', |
|
644 | + '</script>' |
|
645 | + ), '', $output ); |
|
646 | + } |
|
647 | + |
|
648 | + /** |
|
649 | + * Returns the CSS used to render the widget/shortcode settings form. |
|
650 | + * |
|
651 | + * @param bool $advanced If we should include advanced CSS. |
|
652 | + * |
|
653 | + * @return mixed |
|
654 | + */ |
|
655 | + public static function widget_css( $advanced = true ) { |
|
656 | + ob_start(); |
|
657 | + ?> |
|
658 | 658 | |
659 | 659 | <style> |
660 | 660 | <?php if ( $advanced ) : ?> |
@@ -695,45 +695,45 @@ discard block |
||
695 | 695 | </style> |
696 | 696 | |
697 | 697 | <?php |
698 | - $output = ob_get_clean(); |
|
698 | + $output = ob_get_clean(); |
|
699 | 699 | |
700 | - /* |
|
700 | + /* |
|
701 | 701 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
702 | 702 | */ |
703 | 703 | |
704 | - return str_replace( array( |
|
705 | - '<style>', |
|
706 | - '</style>' |
|
707 | - ), '', $output ); |
|
708 | - } |
|
709 | - |
|
710 | - /** |
|
711 | - * Registers the widgets loading settings. |
|
712 | - */ |
|
713 | - public static function load_widgets_setting() { |
|
714 | - register_setting( 'general', 'sd_load_widgets', 'esc_attr' ); |
|
715 | - |
|
716 | - add_settings_field( |
|
717 | - 'sd_load_widgets', |
|
718 | - '<label for="sd_load_widgets">' . __( 'Load Super Duper Widgets' ) . '</label>', |
|
719 | - 'WP_Super_Duper::load_widgets_setting_html', |
|
720 | - 'general' |
|
721 | - ); |
|
722 | - |
|
723 | - } |
|
724 | - |
|
725 | - /** |
|
726 | - * Displays the widgets settings HTML. |
|
727 | - */ |
|
728 | - public static function load_widgets_setting_html() { |
|
729 | - $available_options = array( |
|
730 | - 'yes' => __( 'Yes' ), |
|
731 | - 'no' => __( 'No' ), |
|
732 | - 'auto' => __( 'Auto' ), |
|
733 | - ); |
|
734 | - $selected_option = get_option( 'sd_load_widgets', 'auto' ); |
|
735 | - |
|
736 | - ?> |
|
704 | + return str_replace( array( |
|
705 | + '<style>', |
|
706 | + '</style>' |
|
707 | + ), '', $output ); |
|
708 | + } |
|
709 | + |
|
710 | + /** |
|
711 | + * Registers the widgets loading settings. |
|
712 | + */ |
|
713 | + public static function load_widgets_setting() { |
|
714 | + register_setting( 'general', 'sd_load_widgets', 'esc_attr' ); |
|
715 | + |
|
716 | + add_settings_field( |
|
717 | + 'sd_load_widgets', |
|
718 | + '<label for="sd_load_widgets">' . __( 'Load Super Duper Widgets' ) . '</label>', |
|
719 | + 'WP_Super_Duper::load_widgets_setting_html', |
|
720 | + 'general' |
|
721 | + ); |
|
722 | + |
|
723 | + } |
|
724 | + |
|
725 | + /** |
|
726 | + * Displays the widgets settings HTML. |
|
727 | + */ |
|
728 | + public static function load_widgets_setting_html() { |
|
729 | + $available_options = array( |
|
730 | + 'yes' => __( 'Yes' ), |
|
731 | + 'no' => __( 'No' ), |
|
732 | + 'auto' => __( 'Auto' ), |
|
733 | + ); |
|
734 | + $selected_option = get_option( 'sd_load_widgets', 'auto' ); |
|
735 | + |
|
736 | + ?> |
|
737 | 737 | <select name="sd_load_widgets" id="sd_load_widgets"> |
738 | 738 | <?php foreach ( $available_options as $key => $label ) : ?> |
739 | 739 | <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $selected_option ); ?>><?php echo esc_html( $label ); ?></option> |
@@ -741,558 +741,558 @@ discard block |
||
741 | 741 | </select> |
742 | 742 | <p class="description"><?php _e( 'This option allows you to disable Super Duper widgets and instead only load the blocks and shortcodes.' ); ?></p> |
743 | 743 | <?php |
744 | - } |
|
745 | - |
|
746 | - /** |
|
747 | - * prevent SDv1 errors if register_widget() function used |
|
748 | - */ |
|
749 | - public function _register(){ |
|
750 | - // backwards compatibility |
|
751 | - } |
|
752 | - |
|
753 | - /** |
|
754 | - * Output the version in the admin header. |
|
755 | - */ |
|
756 | - public function generator() { |
|
757 | - |
|
758 | - // We want to set this once. |
|
759 | - if ( empty( $GLOBALS['SD_SET_GENERATOR'] ) ) { |
|
760 | - echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
761 | - $GLOBALS['SD_SET_GENERATOR'] = 1; |
|
762 | - } |
|
763 | - |
|
764 | - } |
|
765 | - |
|
766 | - /** |
|
767 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
768 | - * |
|
769 | - * @param array $args |
|
770 | - * @param array $widget_args |
|
771 | - * @param string $content |
|
772 | - */ |
|
773 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
774 | - echo call_user_func( $this->options['widget_ops']['output'], $args, $widget_args, $content ); |
|
775 | - } |
|
776 | - |
|
777 | - /** |
|
778 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
779 | - * |
|
780 | - * @param string $name |
|
781 | - * |
|
782 | - * @return string |
|
783 | - */ |
|
784 | - public function preview_placeholder_text( $name = '' ) { |
|
785 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
786 | - } |
|
787 | - |
|
788 | - /** |
|
789 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
790 | - * |
|
791 | - * @param $options |
|
792 | - * |
|
793 | - * @return mixed |
|
794 | - */ |
|
795 | - public function string_to_bool( $options ) { |
|
796 | - // convert bool strings to booleans |
|
797 | - foreach ( $options as $key => $val ) { |
|
798 | - if ( $val == 'false' ) { |
|
799 | - $options[ $key ] = false; |
|
800 | - } elseif ( $val == 'true' ) { |
|
801 | - $options[ $key ] = true; |
|
802 | - } |
|
803 | - } |
|
804 | - |
|
805 | - return $options; |
|
806 | - } |
|
807 | - |
|
808 | - /** |
|
809 | - * Get the argument values that are also filterable. |
|
810 | - * |
|
811 | - * @param $instance |
|
812 | - * |
|
813 | - * @since 1.0.12 Don't set checkbox default value if the value is empty. |
|
814 | - * |
|
815 | - * @return array |
|
816 | - */ |
|
817 | - public function argument_values( $instance ) { |
|
818 | - $argument_values = array(); |
|
819 | - |
|
820 | - // set widget instance |
|
821 | - $this->instance = $instance; |
|
822 | - |
|
823 | - if ( empty( $this->arguments ) ) { |
|
824 | - $this->arguments = $this->get_arguments(); |
|
825 | - } |
|
826 | - |
|
827 | - if ( ! empty( $this->arguments ) ) { |
|
828 | - foreach ( $this->arguments as $key => $args ) { |
|
829 | - // set the input name from the key |
|
830 | - $args['name'] = $key; |
|
831 | - // |
|
832 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
833 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
834 | - // don't set default for an empty checkbox |
|
835 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
836 | - $argument_values[ $key ] = $args['default']; |
|
837 | - } |
|
838 | - } |
|
839 | - } |
|
840 | - |
|
841 | - return $argument_values; |
|
842 | - } |
|
843 | - |
|
844 | - /** |
|
845 | - * Get the url path to the current folder. |
|
846 | - * |
|
847 | - * @return string |
|
848 | - */ |
|
849 | - public function get_url() { |
|
850 | - $url = $this->url; |
|
851 | - |
|
852 | - if ( ! $url ) { |
|
853 | - // check if we are inside a plugin |
|
854 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
855 | - |
|
856 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
857 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
858 | - |
|
859 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
860 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
861 | - $this->url = $url; |
|
862 | - } |
|
863 | - } |
|
864 | - |
|
865 | - return $url; |
|
866 | - } |
|
867 | - |
|
868 | - /** |
|
869 | - * General function to check if we are in a preview situation. |
|
870 | - * |
|
871 | - * @since 1.0.6 |
|
872 | - * @return bool |
|
873 | - */ |
|
874 | - public function is_preview() { |
|
875 | - return $this->is_divi_preview() || $this->is_elementor_preview() || $this->is_beaver_preview() || $this->is_siteorigin_preview() || $this->is_cornerstone_preview() || $this->is_fusion_preview() || $this->is_oxygen_preview() || $this->is_block_content_call(); |
|
876 | - } |
|
877 | - |
|
878 | - /** |
|
879 | - * Tests if the current output is inside a Divi preview. |
|
880 | - * |
|
881 | - * @since 1.0.6 |
|
882 | - * @return bool |
|
883 | - */ |
|
884 | - public function is_divi_preview() { |
|
885 | - $result = false; |
|
886 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
887 | - $result = true; |
|
888 | - } |
|
889 | - |
|
890 | - return $result; |
|
891 | - } |
|
892 | - |
|
893 | - /** |
|
894 | - * Tests if the current output is inside a elementor preview. |
|
895 | - * |
|
896 | - * @since 1.0.4 |
|
897 | - * @return bool |
|
898 | - */ |
|
899 | - public function is_elementor_preview() { |
|
900 | - $result = false; |
|
901 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
902 | - $result = true; |
|
903 | - } |
|
904 | - |
|
905 | - return $result; |
|
906 | - } |
|
907 | - |
|
908 | - /** |
|
909 | - * Tests if the current output is inside a Beaver builder preview. |
|
910 | - * |
|
911 | - * @since 1.0.6 |
|
912 | - * @return bool |
|
913 | - */ |
|
914 | - public function is_beaver_preview() { |
|
915 | - $result = false; |
|
916 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
917 | - $result = true; |
|
918 | - } |
|
919 | - |
|
920 | - return $result; |
|
921 | - } |
|
922 | - |
|
923 | - /** |
|
924 | - * Tests if the current output is inside a siteorigin builder preview. |
|
925 | - * |
|
926 | - * @since 1.0.6 |
|
927 | - * @return bool |
|
928 | - */ |
|
929 | - public function is_siteorigin_preview() { |
|
930 | - $result = false; |
|
931 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
932 | - $result = true; |
|
933 | - } |
|
934 | - |
|
935 | - return $result; |
|
936 | - } |
|
937 | - |
|
938 | - /** |
|
939 | - * Tests if the current output is inside a cornerstone builder preview. |
|
940 | - * |
|
941 | - * @since 1.0.8 |
|
942 | - * @return bool |
|
943 | - */ |
|
944 | - public function is_cornerstone_preview() { |
|
945 | - $result = false; |
|
946 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
947 | - $result = true; |
|
948 | - } |
|
949 | - |
|
950 | - return $result; |
|
951 | - } |
|
952 | - |
|
953 | - /** |
|
954 | - * Tests if the current output is inside a fusion builder preview. |
|
955 | - * |
|
956 | - * @since 1.1.0 |
|
957 | - * @return bool |
|
958 | - */ |
|
959 | - public function is_fusion_preview() { |
|
960 | - $result = false; |
|
961 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
962 | - $result = true; |
|
963 | - } |
|
964 | - |
|
965 | - return $result; |
|
966 | - } |
|
967 | - |
|
968 | - /** |
|
969 | - * Tests if the current output is inside a Oxygen builder preview. |
|
970 | - * |
|
971 | - * @since 1.0.18 |
|
972 | - * @return bool |
|
973 | - */ |
|
974 | - public function is_oxygen_preview() { |
|
975 | - $result = false; |
|
976 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
977 | - $result = true; |
|
978 | - } |
|
979 | - |
|
980 | - return $result; |
|
981 | - } |
|
982 | - |
|
983 | - /** |
|
984 | - * Checks if the current call is a ajax call to get the block content. |
|
985 | - * |
|
986 | - * This can be used in your widget to return different content as the block content. |
|
987 | - * |
|
988 | - * @since 1.0.3 |
|
989 | - * @return bool |
|
990 | - */ |
|
991 | - public function is_block_content_call() { |
|
992 | - $result = false; |
|
993 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
994 | - $result = true; |
|
995 | - } |
|
996 | - |
|
997 | - return $result; |
|
998 | - } |
|
999 | - |
|
1000 | - /** |
|
1001 | - * Outputs the options form inputs for the widget/shortcode. |
|
1002 | - * |
|
1003 | - * @param array $instance The widget options. |
|
1004 | - */ |
|
1005 | - public function form( $instance ) { |
|
1006 | - |
|
1007 | - // Set widget instance. |
|
1008 | - $this->instance = $instance; |
|
1009 | - |
|
1010 | - // Set it as a SD widget. |
|
1011 | - echo $this->widget_advanced_toggle(); |
|
1012 | - |
|
1013 | - // Display description. |
|
1014 | - printf( '<p>%s</p>', esc_html( $this->options['widget_ops']['description'] ) ); |
|
1015 | - |
|
1016 | - // Prepare arguments. |
|
1017 | - $arguments_raw = $this->get_arguments(); |
|
1018 | - |
|
1019 | - if ( is_array( $arguments_raw ) ) { |
|
1020 | - |
|
1021 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
1022 | - |
|
1023 | - // Do we have sections? |
|
1024 | - if ( $arguments != $arguments_raw ) { |
|
1025 | - |
|
1026 | - $panel_count = 0; |
|
1027 | - foreach ( $arguments as $key => $args ) { |
|
1028 | - |
|
1029 | - $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
1030 | - $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
1031 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . esc_attr( $icon_class ) . "'></i></button>"; |
|
1032 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
1033 | - |
|
1034 | - foreach ( $args as $k => $a ) { |
|
1035 | - |
|
1036 | - $this->widget_inputs_row_start($k, $a); |
|
1037 | - $this->widget_inputs( $a, $instance ); |
|
1038 | - $this->widget_inputs_row_end($k, $a); |
|
1039 | - |
|
1040 | - } |
|
1041 | - |
|
1042 | - echo "</div>"; |
|
1043 | - |
|
1044 | - $panel_count ++; |
|
1045 | - |
|
1046 | - } |
|
1047 | - |
|
1048 | - } else { |
|
1049 | - |
|
1050 | - foreach ( $arguments as $key => $args ) { |
|
1051 | - $this->widget_inputs_row_start($key, $args); |
|
1052 | - $this->widget_inputs( $args, $instance ); |
|
1053 | - $this->widget_inputs_row_end($key, $args); |
|
1054 | - } |
|
1055 | - |
|
1056 | - } |
|
1057 | - |
|
1058 | - } |
|
1059 | - } |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
1063 | - * |
|
1064 | - * @return string |
|
1065 | - */ |
|
1066 | - public function widget_advanced_toggle() { |
|
1067 | - |
|
1068 | - return sprintf( |
|
1069 | - '<input type="hidden" class="sd-show-advanced" value="%s" />', |
|
1070 | - (int) $this->block_show_advanced() |
|
1071 | - ); |
|
1072 | - |
|
1073 | - } |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * Check if we need to show advanced options. |
|
1077 | - * |
|
1078 | - * @return bool |
|
1079 | - */ |
|
1080 | - public function block_show_advanced() { |
|
1081 | - $show = false; |
|
1082 | - $arguments = $this->get_arguments(); |
|
1083 | - |
|
1084 | - if ( ! empty( $arguments ) ) { |
|
1085 | - foreach ( $arguments as $argument ) { |
|
1086 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
1087 | - $show = true; |
|
1088 | - break; // no need to continue if we know we have it |
|
1089 | - } |
|
1090 | - } |
|
1091 | - } |
|
1092 | - |
|
1093 | - return $show; |
|
1094 | - } |
|
1095 | - |
|
1096 | - /** |
|
1097 | - * Groups widget arguments. |
|
1098 | - * |
|
1099 | - * @param array $arguments |
|
1100 | - * |
|
1101 | - * @return array |
|
1102 | - */ |
|
1103 | - public function group_arguments( $arguments ) { |
|
1104 | - |
|
1105 | - if ( ! empty( $arguments ) ) { |
|
1106 | - $temp_arguments = array(); |
|
1107 | - $general = __( "General" ); |
|
1108 | - $add_sections = false; |
|
1109 | - foreach ( $arguments as $key => $args ) { |
|
1110 | - if ( isset( $args['group'] ) ) { |
|
1111 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
1112 | - $add_sections = true; |
|
1113 | - } else { |
|
1114 | - $temp_arguments[ $general ][ $key ] = $args; |
|
1115 | - } |
|
1116 | - } |
|
1117 | - |
|
1118 | - // only add sections if more than one |
|
1119 | - if ( $add_sections ) { |
|
1120 | - $arguments = $temp_arguments; |
|
1121 | - } |
|
1122 | - } |
|
1123 | - |
|
1124 | - return $arguments; |
|
1125 | - } |
|
1126 | - |
|
1127 | - public function widget_inputs_row_start($key, $args){ |
|
1128 | - if(!empty($args['row'])){ |
|
1129 | - // maybe open |
|
1130 | - if(!empty($args['row']['open'])){ |
|
1131 | - ?> |
|
744 | + } |
|
745 | + |
|
746 | + /** |
|
747 | + * prevent SDv1 errors if register_widget() function used |
|
748 | + */ |
|
749 | + public function _register(){ |
|
750 | + // backwards compatibility |
|
751 | + } |
|
752 | + |
|
753 | + /** |
|
754 | + * Output the version in the admin header. |
|
755 | + */ |
|
756 | + public function generator() { |
|
757 | + |
|
758 | + // We want to set this once. |
|
759 | + if ( empty( $GLOBALS['SD_SET_GENERATOR'] ) ) { |
|
760 | + echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
761 | + $GLOBALS['SD_SET_GENERATOR'] = 1; |
|
762 | + } |
|
763 | + |
|
764 | + } |
|
765 | + |
|
766 | + /** |
|
767 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
768 | + * |
|
769 | + * @param array $args |
|
770 | + * @param array $widget_args |
|
771 | + * @param string $content |
|
772 | + */ |
|
773 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
774 | + echo call_user_func( $this->options['widget_ops']['output'], $args, $widget_args, $content ); |
|
775 | + } |
|
776 | + |
|
777 | + /** |
|
778 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
779 | + * |
|
780 | + * @param string $name |
|
781 | + * |
|
782 | + * @return string |
|
783 | + */ |
|
784 | + public function preview_placeholder_text( $name = '' ) { |
|
785 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
786 | + } |
|
787 | + |
|
788 | + /** |
|
789 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
790 | + * |
|
791 | + * @param $options |
|
792 | + * |
|
793 | + * @return mixed |
|
794 | + */ |
|
795 | + public function string_to_bool( $options ) { |
|
796 | + // convert bool strings to booleans |
|
797 | + foreach ( $options as $key => $val ) { |
|
798 | + if ( $val == 'false' ) { |
|
799 | + $options[ $key ] = false; |
|
800 | + } elseif ( $val == 'true' ) { |
|
801 | + $options[ $key ] = true; |
|
802 | + } |
|
803 | + } |
|
804 | + |
|
805 | + return $options; |
|
806 | + } |
|
807 | + |
|
808 | + /** |
|
809 | + * Get the argument values that are also filterable. |
|
810 | + * |
|
811 | + * @param $instance |
|
812 | + * |
|
813 | + * @since 1.0.12 Don't set checkbox default value if the value is empty. |
|
814 | + * |
|
815 | + * @return array |
|
816 | + */ |
|
817 | + public function argument_values( $instance ) { |
|
818 | + $argument_values = array(); |
|
819 | + |
|
820 | + // set widget instance |
|
821 | + $this->instance = $instance; |
|
822 | + |
|
823 | + if ( empty( $this->arguments ) ) { |
|
824 | + $this->arguments = $this->get_arguments(); |
|
825 | + } |
|
826 | + |
|
827 | + if ( ! empty( $this->arguments ) ) { |
|
828 | + foreach ( $this->arguments as $key => $args ) { |
|
829 | + // set the input name from the key |
|
830 | + $args['name'] = $key; |
|
831 | + // |
|
832 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
833 | + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
834 | + // don't set default for an empty checkbox |
|
835 | + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
836 | + $argument_values[ $key ] = $args['default']; |
|
837 | + } |
|
838 | + } |
|
839 | + } |
|
840 | + |
|
841 | + return $argument_values; |
|
842 | + } |
|
843 | + |
|
844 | + /** |
|
845 | + * Get the url path to the current folder. |
|
846 | + * |
|
847 | + * @return string |
|
848 | + */ |
|
849 | + public function get_url() { |
|
850 | + $url = $this->url; |
|
851 | + |
|
852 | + if ( ! $url ) { |
|
853 | + // check if we are inside a plugin |
|
854 | + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
855 | + |
|
856 | + $dir_parts = explode( "/wp-content/", $file_dir ); |
|
857 | + $url_parts = explode( "/wp-content/", plugins_url() ); |
|
858 | + |
|
859 | + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
860 | + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
861 | + $this->url = $url; |
|
862 | + } |
|
863 | + } |
|
864 | + |
|
865 | + return $url; |
|
866 | + } |
|
867 | + |
|
868 | + /** |
|
869 | + * General function to check if we are in a preview situation. |
|
870 | + * |
|
871 | + * @since 1.0.6 |
|
872 | + * @return bool |
|
873 | + */ |
|
874 | + public function is_preview() { |
|
875 | + return $this->is_divi_preview() || $this->is_elementor_preview() || $this->is_beaver_preview() || $this->is_siteorigin_preview() || $this->is_cornerstone_preview() || $this->is_fusion_preview() || $this->is_oxygen_preview() || $this->is_block_content_call(); |
|
876 | + } |
|
877 | + |
|
878 | + /** |
|
879 | + * Tests if the current output is inside a Divi preview. |
|
880 | + * |
|
881 | + * @since 1.0.6 |
|
882 | + * @return bool |
|
883 | + */ |
|
884 | + public function is_divi_preview() { |
|
885 | + $result = false; |
|
886 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
887 | + $result = true; |
|
888 | + } |
|
889 | + |
|
890 | + return $result; |
|
891 | + } |
|
892 | + |
|
893 | + /** |
|
894 | + * Tests if the current output is inside a elementor preview. |
|
895 | + * |
|
896 | + * @since 1.0.4 |
|
897 | + * @return bool |
|
898 | + */ |
|
899 | + public function is_elementor_preview() { |
|
900 | + $result = false; |
|
901 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
902 | + $result = true; |
|
903 | + } |
|
904 | + |
|
905 | + return $result; |
|
906 | + } |
|
907 | + |
|
908 | + /** |
|
909 | + * Tests if the current output is inside a Beaver builder preview. |
|
910 | + * |
|
911 | + * @since 1.0.6 |
|
912 | + * @return bool |
|
913 | + */ |
|
914 | + public function is_beaver_preview() { |
|
915 | + $result = false; |
|
916 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
917 | + $result = true; |
|
918 | + } |
|
919 | + |
|
920 | + return $result; |
|
921 | + } |
|
922 | + |
|
923 | + /** |
|
924 | + * Tests if the current output is inside a siteorigin builder preview. |
|
925 | + * |
|
926 | + * @since 1.0.6 |
|
927 | + * @return bool |
|
928 | + */ |
|
929 | + public function is_siteorigin_preview() { |
|
930 | + $result = false; |
|
931 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
932 | + $result = true; |
|
933 | + } |
|
934 | + |
|
935 | + return $result; |
|
936 | + } |
|
937 | + |
|
938 | + /** |
|
939 | + * Tests if the current output is inside a cornerstone builder preview. |
|
940 | + * |
|
941 | + * @since 1.0.8 |
|
942 | + * @return bool |
|
943 | + */ |
|
944 | + public function is_cornerstone_preview() { |
|
945 | + $result = false; |
|
946 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
947 | + $result = true; |
|
948 | + } |
|
949 | + |
|
950 | + return $result; |
|
951 | + } |
|
952 | + |
|
953 | + /** |
|
954 | + * Tests if the current output is inside a fusion builder preview. |
|
955 | + * |
|
956 | + * @since 1.1.0 |
|
957 | + * @return bool |
|
958 | + */ |
|
959 | + public function is_fusion_preview() { |
|
960 | + $result = false; |
|
961 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
962 | + $result = true; |
|
963 | + } |
|
964 | + |
|
965 | + return $result; |
|
966 | + } |
|
967 | + |
|
968 | + /** |
|
969 | + * Tests if the current output is inside a Oxygen builder preview. |
|
970 | + * |
|
971 | + * @since 1.0.18 |
|
972 | + * @return bool |
|
973 | + */ |
|
974 | + public function is_oxygen_preview() { |
|
975 | + $result = false; |
|
976 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
977 | + $result = true; |
|
978 | + } |
|
979 | + |
|
980 | + return $result; |
|
981 | + } |
|
982 | + |
|
983 | + /** |
|
984 | + * Checks if the current call is a ajax call to get the block content. |
|
985 | + * |
|
986 | + * This can be used in your widget to return different content as the block content. |
|
987 | + * |
|
988 | + * @since 1.0.3 |
|
989 | + * @return bool |
|
990 | + */ |
|
991 | + public function is_block_content_call() { |
|
992 | + $result = false; |
|
993 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
994 | + $result = true; |
|
995 | + } |
|
996 | + |
|
997 | + return $result; |
|
998 | + } |
|
999 | + |
|
1000 | + /** |
|
1001 | + * Outputs the options form inputs for the widget/shortcode. |
|
1002 | + * |
|
1003 | + * @param array $instance The widget options. |
|
1004 | + */ |
|
1005 | + public function form( $instance ) { |
|
1006 | + |
|
1007 | + // Set widget instance. |
|
1008 | + $this->instance = $instance; |
|
1009 | + |
|
1010 | + // Set it as a SD widget. |
|
1011 | + echo $this->widget_advanced_toggle(); |
|
1012 | + |
|
1013 | + // Display description. |
|
1014 | + printf( '<p>%s</p>', esc_html( $this->options['widget_ops']['description'] ) ); |
|
1015 | + |
|
1016 | + // Prepare arguments. |
|
1017 | + $arguments_raw = $this->get_arguments(); |
|
1018 | + |
|
1019 | + if ( is_array( $arguments_raw ) ) { |
|
1020 | + |
|
1021 | + $arguments = $this->group_arguments( $arguments_raw ); |
|
1022 | + |
|
1023 | + // Do we have sections? |
|
1024 | + if ( $arguments != $arguments_raw ) { |
|
1025 | + |
|
1026 | + $panel_count = 0; |
|
1027 | + foreach ( $arguments as $key => $args ) { |
|
1028 | + |
|
1029 | + $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
1030 | + $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
1031 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . esc_attr( $icon_class ) . "'></i></button>"; |
|
1032 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
1033 | + |
|
1034 | + foreach ( $args as $k => $a ) { |
|
1035 | + |
|
1036 | + $this->widget_inputs_row_start($k, $a); |
|
1037 | + $this->widget_inputs( $a, $instance ); |
|
1038 | + $this->widget_inputs_row_end($k, $a); |
|
1039 | + |
|
1040 | + } |
|
1041 | + |
|
1042 | + echo "</div>"; |
|
1043 | + |
|
1044 | + $panel_count ++; |
|
1045 | + |
|
1046 | + } |
|
1047 | + |
|
1048 | + } else { |
|
1049 | + |
|
1050 | + foreach ( $arguments as $key => $args ) { |
|
1051 | + $this->widget_inputs_row_start($key, $args); |
|
1052 | + $this->widget_inputs( $args, $instance ); |
|
1053 | + $this->widget_inputs_row_end($key, $args); |
|
1054 | + } |
|
1055 | + |
|
1056 | + } |
|
1057 | + |
|
1058 | + } |
|
1059 | + } |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
1063 | + * |
|
1064 | + * @return string |
|
1065 | + */ |
|
1066 | + public function widget_advanced_toggle() { |
|
1067 | + |
|
1068 | + return sprintf( |
|
1069 | + '<input type="hidden" class="sd-show-advanced" value="%s" />', |
|
1070 | + (int) $this->block_show_advanced() |
|
1071 | + ); |
|
1072 | + |
|
1073 | + } |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * Check if we need to show advanced options. |
|
1077 | + * |
|
1078 | + * @return bool |
|
1079 | + */ |
|
1080 | + public function block_show_advanced() { |
|
1081 | + $show = false; |
|
1082 | + $arguments = $this->get_arguments(); |
|
1083 | + |
|
1084 | + if ( ! empty( $arguments ) ) { |
|
1085 | + foreach ( $arguments as $argument ) { |
|
1086 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
1087 | + $show = true; |
|
1088 | + break; // no need to continue if we know we have it |
|
1089 | + } |
|
1090 | + } |
|
1091 | + } |
|
1092 | + |
|
1093 | + return $show; |
|
1094 | + } |
|
1095 | + |
|
1096 | + /** |
|
1097 | + * Groups widget arguments. |
|
1098 | + * |
|
1099 | + * @param array $arguments |
|
1100 | + * |
|
1101 | + * @return array |
|
1102 | + */ |
|
1103 | + public function group_arguments( $arguments ) { |
|
1104 | + |
|
1105 | + if ( ! empty( $arguments ) ) { |
|
1106 | + $temp_arguments = array(); |
|
1107 | + $general = __( "General" ); |
|
1108 | + $add_sections = false; |
|
1109 | + foreach ( $arguments as $key => $args ) { |
|
1110 | + if ( isset( $args['group'] ) ) { |
|
1111 | + $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
1112 | + $add_sections = true; |
|
1113 | + } else { |
|
1114 | + $temp_arguments[ $general ][ $key ] = $args; |
|
1115 | + } |
|
1116 | + } |
|
1117 | + |
|
1118 | + // only add sections if more than one |
|
1119 | + if ( $add_sections ) { |
|
1120 | + $arguments = $temp_arguments; |
|
1121 | + } |
|
1122 | + } |
|
1123 | + |
|
1124 | + return $arguments; |
|
1125 | + } |
|
1126 | + |
|
1127 | + public function widget_inputs_row_start($key, $args){ |
|
1128 | + if(!empty($args['row'])){ |
|
1129 | + // maybe open |
|
1130 | + if(!empty($args['row']['open'])){ |
|
1131 | + ?> |
|
1132 | 1132 | <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
1133 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
1134 | - } ?>'> |
|
1133 | + echo $this->convert_element_require( $args['row']['element_require'] ); |
|
1134 | + } ?>'> |
|
1135 | 1135 | <?php if(!empty($args['row']['title'])){ ?> |
1136 | 1136 | <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
1137 | 1137 | <?php }?> |
1138 | 1138 | <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
1139 | 1139 | <div class='col pr-2'> |
1140 | 1140 | <?php |
1141 | - }elseif(!empty($args['row']['close'])){ |
|
1142 | - echo "<div class='col pl-0'>"; |
|
1143 | - }else{ |
|
1144 | - echo "<div class='col pl-0 pr-2'>"; |
|
1145 | - } |
|
1146 | - } |
|
1147 | - } |
|
1148 | - |
|
1149 | - /** |
|
1150 | - * Convert require element. |
|
1151 | - * |
|
1152 | - * @since 1.0.0 |
|
1153 | - * |
|
1154 | - * @param string $input Input element. |
|
1155 | - * |
|
1156 | - * @return string $output |
|
1157 | - */ |
|
1158 | - public function convert_element_require( $input ) { |
|
1159 | - |
|
1160 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
1161 | - |
|
1162 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
1163 | - "jQuery(form).find('[data-argument=\"", |
|
1164 | - "\"]').find('input,select,textarea').val()" |
|
1165 | - ), $input ) ); |
|
1166 | - |
|
1167 | - return $output; |
|
1168 | - } |
|
1169 | - |
|
1170 | - /** |
|
1171 | - * Get the widget input description html. |
|
1172 | - * |
|
1173 | - * @param $args |
|
1174 | - * |
|
1175 | - * @return string |
|
1176 | - * @todo, need to make its own tooltip script |
|
1177 | - */ |
|
1178 | - public function widget_field_desc( $args ) { |
|
1179 | - |
|
1180 | - $description = ''; |
|
1181 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
1182 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
1183 | - $description = $this->desc_tip( $args['desc'] ); |
|
1184 | - } else { |
|
1185 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
1186 | - } |
|
1187 | - } |
|
1188 | - |
|
1189 | - return $description; |
|
1190 | - } |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * Get the tool tip html. |
|
1194 | - * |
|
1195 | - * @param $tip |
|
1196 | - * @param bool $allow_html |
|
1197 | - * |
|
1198 | - * @return string |
|
1199 | - */ |
|
1200 | - public function desc_tip( $tip, $allow_html = false ) { |
|
1201 | - if ( $allow_html ) { |
|
1202 | - $tip = $this->sanitize_tooltip( $tip ); |
|
1203 | - } else { |
|
1204 | - $tip = esc_attr( $tip ); |
|
1205 | - } |
|
1206 | - |
|
1207 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
1208 | - } |
|
1209 | - |
|
1210 | - /** |
|
1211 | - * Sanitize a string destined to be a tooltip. |
|
1212 | - * |
|
1213 | - * @param string $var |
|
1214 | - * |
|
1215 | - * @return string |
|
1216 | - */ |
|
1217 | - public function sanitize_tooltip( $var ) { |
|
1218 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
1219 | - 'br' => array(), |
|
1220 | - 'em' => array(), |
|
1221 | - 'strong' => array(), |
|
1222 | - 'small' => array(), |
|
1223 | - 'span' => array(), |
|
1224 | - 'ul' => array(), |
|
1225 | - 'li' => array(), |
|
1226 | - 'ol' => array(), |
|
1227 | - 'p' => array(), |
|
1228 | - ) ) ); |
|
1229 | - } |
|
1230 | - |
|
1231 | - /** |
|
1232 | - * Builds the inputs for the widget options. |
|
1233 | - * |
|
1234 | - * @param $args |
|
1235 | - * @param $instance |
|
1236 | - */ |
|
1237 | - public function widget_inputs( $args, $instance ) { |
|
1238 | - |
|
1239 | - $class = ""; |
|
1240 | - $element_require = ""; |
|
1241 | - $custom_attributes = ""; |
|
1242 | - |
|
1243 | - // get value |
|
1244 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
1245 | - $value = $instance[ $args['name'] ]; |
|
1246 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
1247 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
1248 | - } else { |
|
1249 | - $value = ''; |
|
1250 | - } |
|
1251 | - |
|
1252 | - // get placeholder |
|
1253 | - if ( ! empty( $args['placeholder'] ) ) { |
|
1254 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
1255 | - } else { |
|
1256 | - $placeholder = ''; |
|
1257 | - } |
|
1258 | - |
|
1259 | - // get if advanced |
|
1260 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
1261 | - $class .= " sd-advanced-setting "; |
|
1262 | - } |
|
1263 | - |
|
1264 | - // element_require |
|
1265 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
1266 | - $element_require = $args['element_require']; |
|
1267 | - } |
|
1268 | - |
|
1269 | - // custom_attributes |
|
1270 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
1271 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
1272 | - } |
|
1273 | - |
|
1274 | - |
|
1275 | - // before wrapper |
|
1276 | - ?> |
|
1141 | + }elseif(!empty($args['row']['close'])){ |
|
1142 | + echo "<div class='col pl-0'>"; |
|
1143 | + }else{ |
|
1144 | + echo "<div class='col pl-0 pr-2'>"; |
|
1145 | + } |
|
1146 | + } |
|
1147 | + } |
|
1148 | + |
|
1149 | + /** |
|
1150 | + * Convert require element. |
|
1151 | + * |
|
1152 | + * @since 1.0.0 |
|
1153 | + * |
|
1154 | + * @param string $input Input element. |
|
1155 | + * |
|
1156 | + * @return string $output |
|
1157 | + */ |
|
1158 | + public function convert_element_require( $input ) { |
|
1159 | + |
|
1160 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
1161 | + |
|
1162 | + $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
1163 | + "jQuery(form).find('[data-argument=\"", |
|
1164 | + "\"]').find('input,select,textarea').val()" |
|
1165 | + ), $input ) ); |
|
1166 | + |
|
1167 | + return $output; |
|
1168 | + } |
|
1169 | + |
|
1170 | + /** |
|
1171 | + * Get the widget input description html. |
|
1172 | + * |
|
1173 | + * @param $args |
|
1174 | + * |
|
1175 | + * @return string |
|
1176 | + * @todo, need to make its own tooltip script |
|
1177 | + */ |
|
1178 | + public function widget_field_desc( $args ) { |
|
1179 | + |
|
1180 | + $description = ''; |
|
1181 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
1182 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
1183 | + $description = $this->desc_tip( $args['desc'] ); |
|
1184 | + } else { |
|
1185 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
1186 | + } |
|
1187 | + } |
|
1188 | + |
|
1189 | + return $description; |
|
1190 | + } |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * Get the tool tip html. |
|
1194 | + * |
|
1195 | + * @param $tip |
|
1196 | + * @param bool $allow_html |
|
1197 | + * |
|
1198 | + * @return string |
|
1199 | + */ |
|
1200 | + public function desc_tip( $tip, $allow_html = false ) { |
|
1201 | + if ( $allow_html ) { |
|
1202 | + $tip = $this->sanitize_tooltip( $tip ); |
|
1203 | + } else { |
|
1204 | + $tip = esc_attr( $tip ); |
|
1205 | + } |
|
1206 | + |
|
1207 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
1208 | + } |
|
1209 | + |
|
1210 | + /** |
|
1211 | + * Sanitize a string destined to be a tooltip. |
|
1212 | + * |
|
1213 | + * @param string $var |
|
1214 | + * |
|
1215 | + * @return string |
|
1216 | + */ |
|
1217 | + public function sanitize_tooltip( $var ) { |
|
1218 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
1219 | + 'br' => array(), |
|
1220 | + 'em' => array(), |
|
1221 | + 'strong' => array(), |
|
1222 | + 'small' => array(), |
|
1223 | + 'span' => array(), |
|
1224 | + 'ul' => array(), |
|
1225 | + 'li' => array(), |
|
1226 | + 'ol' => array(), |
|
1227 | + 'p' => array(), |
|
1228 | + ) ) ); |
|
1229 | + } |
|
1230 | + |
|
1231 | + /** |
|
1232 | + * Builds the inputs for the widget options. |
|
1233 | + * |
|
1234 | + * @param $args |
|
1235 | + * @param $instance |
|
1236 | + */ |
|
1237 | + public function widget_inputs( $args, $instance ) { |
|
1238 | + |
|
1239 | + $class = ""; |
|
1240 | + $element_require = ""; |
|
1241 | + $custom_attributes = ""; |
|
1242 | + |
|
1243 | + // get value |
|
1244 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
1245 | + $value = $instance[ $args['name'] ]; |
|
1246 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
1247 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
1248 | + } else { |
|
1249 | + $value = ''; |
|
1250 | + } |
|
1251 | + |
|
1252 | + // get placeholder |
|
1253 | + if ( ! empty( $args['placeholder'] ) ) { |
|
1254 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
1255 | + } else { |
|
1256 | + $placeholder = ''; |
|
1257 | + } |
|
1258 | + |
|
1259 | + // get if advanced |
|
1260 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
1261 | + $class .= " sd-advanced-setting "; |
|
1262 | + } |
|
1263 | + |
|
1264 | + // element_require |
|
1265 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
1266 | + $element_require = $args['element_require']; |
|
1267 | + } |
|
1268 | + |
|
1269 | + // custom_attributes |
|
1270 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
1271 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
1272 | + } |
|
1273 | + |
|
1274 | + |
|
1275 | + // before wrapper |
|
1276 | + ?> |
|
1277 | 1277 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
1278 | 1278 | data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
1279 | 1279 | data-element_require='<?php if ( $element_require ) { |
1280 | - echo $this->convert_element_require( $element_require ); |
|
1281 | - } ?>' |
|
1280 | + echo $this->convert_element_require( $element_require ); |
|
1281 | + } ?>' |
|
1282 | 1282 | > |
1283 | 1283 | <?php |
1284 | 1284 | |
1285 | 1285 | |
1286 | - switch ( $args['type'] ) { |
|
1287 | - //array('text','password','number','email','tel','url','color') |
|
1288 | - case "text": |
|
1289 | - case "password": |
|
1290 | - case "number": |
|
1291 | - case "email": |
|
1292 | - case "tel": |
|
1293 | - case "url": |
|
1294 | - case "color": |
|
1295 | - ?> |
|
1286 | + switch ( $args['type'] ) { |
|
1287 | + //array('text','password','number','email','tel','url','color') |
|
1288 | + case "text": |
|
1289 | + case "password": |
|
1290 | + case "number": |
|
1291 | + case "email": |
|
1292 | + case "tel": |
|
1293 | + case "url": |
|
1294 | + case "color": |
|
1295 | + ?> |
|
1296 | 1296 | <label |
1297 | 1297 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
1298 | 1298 | <input <?php echo $placeholder; ?> class="widefat" |
@@ -1303,47 +1303,47 @@ discard block |
||
1303 | 1303 | value="<?php echo esc_attr( $value ); ?>"> |
1304 | 1304 | <?php |
1305 | 1305 | |
1306 | - break; |
|
1307 | - case "select": |
|
1308 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
1309 | - if ( $multiple ) { |
|
1310 | - if ( empty( $value ) ) { |
|
1311 | - $value = array(); |
|
1312 | - } |
|
1313 | - } |
|
1314 | - ?> |
|
1306 | + break; |
|
1307 | + case "select": |
|
1308 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
1309 | + if ( $multiple ) { |
|
1310 | + if ( empty( $value ) ) { |
|
1311 | + $value = array(); |
|
1312 | + } |
|
1313 | + } |
|
1314 | + ?> |
|
1315 | 1315 | <label |
1316 | 1316 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
1317 | 1317 | <select <?php echo $placeholder; ?> class="widefat" |
1318 | 1318 | <?php echo $custom_attributes; ?> |
1319 | 1319 | id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
1320 | 1320 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
1321 | - if ( $multiple ) { |
|
1322 | - echo "[]"; |
|
1323 | - } ?>" |
|
1321 | + if ( $multiple ) { |
|
1322 | + echo "[]"; |
|
1323 | + } ?>" |
|
1324 | 1324 | <?php if ( $multiple ) { |
1325 | - echo "multiple"; |
|
1326 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
1327 | - ?> |
|
1325 | + echo "multiple"; |
|
1326 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
1327 | + ?> |
|
1328 | 1328 | > |
1329 | 1329 | <?php |
1330 | 1330 | |
1331 | - if ( ! empty( $args['options'] ) ) { |
|
1332 | - foreach ( $args['options'] as $val => $label ) { |
|
1333 | - if ( $multiple ) { |
|
1334 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
1335 | - } else { |
|
1336 | - $selected = selected( $value, $val, false ); |
|
1337 | - } |
|
1338 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
1339 | - } |
|
1340 | - } |
|
1341 | - ?> |
|
1331 | + if ( ! empty( $args['options'] ) ) { |
|
1332 | + foreach ( $args['options'] as $val => $label ) { |
|
1333 | + if ( $multiple ) { |
|
1334 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
1335 | + } else { |
|
1336 | + $selected = selected( $value, $val, false ); |
|
1337 | + } |
|
1338 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
1339 | + } |
|
1340 | + } |
|
1341 | + ?> |
|
1342 | 1342 | </select> |
1343 | 1343 | <?php |
1344 | - break; |
|
1345 | - case "checkbox": |
|
1346 | - ?> |
|
1344 | + break; |
|
1345 | + case "checkbox": |
|
1346 | + ?> |
|
1347 | 1347 | <input <?php echo $placeholder; ?> |
1348 | 1348 | <?php checked( 1, $value, true ) ?> |
1349 | 1349 | <?php echo $custom_attributes; ?> |
@@ -1353,9 +1353,9 @@ discard block |
||
1353 | 1353 | <label |
1354 | 1354 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
1355 | 1355 | <?php |
1356 | - break; |
|
1357 | - case "textarea": |
|
1358 | - ?> |
|
1356 | + break; |
|
1357 | + case "textarea": |
|
1358 | + ?> |
|
1359 | 1359 | <label |
1360 | 1360 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
1361 | 1361 | <textarea <?php echo $placeholder; ?> class="widefat" |
@@ -1365,218 +1365,218 @@ discard block |
||
1365 | 1365 | ><?php echo esc_attr( $value ); ?></textarea> |
1366 | 1366 | <?php |
1367 | 1367 | |
1368 | - break; |
|
1369 | - case "hidden": |
|
1370 | - ?> |
|
1368 | + break; |
|
1369 | + case "hidden": |
|
1370 | + ?> |
|
1371 | 1371 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
1372 | 1372 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
1373 | 1373 | value="<?php echo esc_attr( $value ); ?>"> |
1374 | 1374 | <?php |
1375 | - break; |
|
1376 | - default: |
|
1377 | - echo "No input type found!"; // @todo we need to add more input types. |
|
1378 | - } |
|
1375 | + break; |
|
1376 | + default: |
|
1377 | + echo "No input type found!"; // @todo we need to add more input types. |
|
1378 | + } |
|
1379 | 1379 | |
1380 | - // after wrapper |
|
1381 | - ?> |
|
1380 | + // after wrapper |
|
1381 | + ?> |
|
1382 | 1382 | </p> |
1383 | 1383 | <?php |
1384 | - } |
|
1385 | - |
|
1386 | - /** |
|
1387 | - * Convert an array of attributes to JS object or HTML attributes string. |
|
1388 | - * |
|
1389 | - * @todo there is prob a faster way to do this, also we could add some validation here. |
|
1390 | - * |
|
1391 | - * @param $attributes |
|
1392 | - * |
|
1393 | - * @return string |
|
1394 | - */ |
|
1395 | - public function array_to_attributes( $attributes, $html = false ) { |
|
1396 | - |
|
1397 | - if ( ! is_array( $attributes ) ) { |
|
1398 | - return ''; |
|
1399 | - } |
|
1400 | - |
|
1401 | - $output = ''; |
|
1402 | - foreach ( $attributes as $name => $value ) { |
|
1403 | - |
|
1404 | - if ( $html ) { |
|
1405 | - |
|
1406 | - if ( true === $value ) { |
|
1407 | - $output .= esc_html( $name ) . ' '; |
|
1408 | - } else if ( false !== $value ) { |
|
1409 | - $output .= sprintf( '%s="%s" ', esc_html( $name ), trim( esc_attr( $value ) ) ); |
|
1410 | - } |
|
1411 | - |
|
1412 | - } else { |
|
1413 | - $output .= sprintf( "'%s': '%s',", esc_js( $name ), is_bool( $value ) ? $value : trim( esc_js( $value ) ) ); |
|
1414 | - } |
|
1415 | - |
|
1416 | - } |
|
1417 | - |
|
1418 | - return $output; |
|
1419 | - } |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * Constructs id attributes for use in WP_Widget::form() fields. |
|
1423 | - * |
|
1424 | - * This function should be used in form() methods to create id attributes |
|
1425 | - * for fields to be saved by WP_Widget::update(). |
|
1426 | - * |
|
1427 | - * @since 2.8.0 |
|
1428 | - * @since 4.4.0 Array format field IDs are now accepted. |
|
1429 | - * |
|
1430 | - * @param string $field_name Field name. |
|
1431 | - * |
|
1432 | - * @return string ID attribute for `$field_name`. |
|
1433 | - */ |
|
1434 | - public function get_field_id( $field_name ) { |
|
1435 | - |
|
1436 | - $field_name = str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ); |
|
1437 | - $field_name = trim( $field_name, '-' ); |
|
1438 | - |
|
1439 | - return 'widget-' . $this->base_id . '-' . $this->get_number() . '-' . $field_name; |
|
1440 | - } |
|
1441 | - |
|
1442 | - /** |
|
1443 | - * Returns the instance number. |
|
1444 | - * |
|
1445 | - * @return int |
|
1446 | - */ |
|
1447 | - public function get_number() { |
|
1448 | - static $number = 1; |
|
1449 | - |
|
1450 | - if ( isset( $this->output_types['widget'] ) ) { |
|
1451 | - return $this->output_types['widget']->number; |
|
1452 | - } |
|
1453 | - |
|
1454 | - if ( empty( $this->number ) ) { |
|
1455 | - $this->number = $number; |
|
1456 | - $number ++; |
|
1457 | - } |
|
1458 | - |
|
1459 | - return $this->number; |
|
1460 | - } |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * Get the widget input title html. |
|
1464 | - * |
|
1465 | - * @param $args |
|
1466 | - * |
|
1467 | - * @return string |
|
1468 | - */ |
|
1469 | - public function widget_field_title( $args ) { |
|
1470 | - |
|
1471 | - $title = ''; |
|
1472 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
1473 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
1474 | - $title = $this->get_widget_icon( $args['icon'], $args['title'] ); |
|
1475 | - } else { |
|
1476 | - $title = esc_attr($args['title']); |
|
1477 | - } |
|
1478 | - } |
|
1479 | - |
|
1480 | - return $title; |
|
1481 | - } |
|
1482 | - |
|
1483 | - /** |
|
1484 | - * Retrieves the icon to use for widgets / blocks. |
|
1485 | - * |
|
1486 | - * @return array |
|
1487 | - */ |
|
1488 | - public function get_widget_icon( $icon = 'box-top', $title = '' ) { |
|
1489 | - if($icon=='box-top'){ |
|
1490 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
1491 | - }elseif($icon=='box-right'){ |
|
1492 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
1493 | - }elseif($icon=='box-bottom'){ |
|
1494 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
1495 | - }elseif($icon=='box-left'){ |
|
1496 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
1497 | - } |
|
1498 | - } |
|
1499 | - |
|
1500 | - /** |
|
1501 | - * Constructs name attributes for use in form() fields |
|
1502 | - * |
|
1503 | - * This function should be used in form() methods to create name attributes for fields |
|
1504 | - * to be saved by update() |
|
1505 | - * |
|
1506 | - * @since 2.8.0 |
|
1507 | - * @since 4.4.0 Array format field names are now accepted. |
|
1508 | - * |
|
1509 | - * @param string $field_name Field name. |
|
1510 | - * |
|
1511 | - * @return string Name attribute for `$field_name`. |
|
1512 | - */ |
|
1513 | - public function get_field_name( $field_name ) { |
|
1514 | - $pos = strpos( $field_name, '[' ); |
|
1515 | - |
|
1516 | - if ( false !== $pos ) { |
|
1517 | - // Replace the first occurrence of '[' with ']['. |
|
1518 | - $field_name = '[' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); |
|
1519 | - } else { |
|
1520 | - $field_name = '[' . $field_name . ']'; |
|
1521 | - } |
|
1522 | - |
|
1523 | - return 'widget-' . $this->base_id . '[' . $this->get_number() . ']' . $field_name; |
|
1524 | - } |
|
1525 | - |
|
1526 | - public function widget_inputs_row_end($key, $args){ |
|
1527 | - if(!empty($args['row'])){ |
|
1528 | - // maybe close |
|
1529 | - if(!empty($args['row']['close'])){ |
|
1530 | - echo "</div></div>"; |
|
1531 | - } |
|
1532 | - |
|
1533 | - echo "</div>"; |
|
1534 | - } |
|
1535 | - } |
|
1536 | - |
|
1537 | - /** |
|
1538 | - * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
1539 | - * |
|
1540 | - * @param array $rules |
|
1541 | - * |
|
1542 | - * @since 1.0.20 |
|
1543 | - * @return string |
|
1544 | - */ |
|
1545 | - public function get_instance_style($rules = array()){ |
|
1546 | - $css = ''; |
|
1547 | - |
|
1548 | - if(!empty($rules)){ |
|
1549 | - $rules = array_unique($rules); |
|
1550 | - $instance_hash = $this->get_instance_hash(); |
|
1551 | - $css .= "<style>"; |
|
1552 | - foreach($rules as $rule){ |
|
1553 | - $css .= ".sdel-$instance_hash $rule"; |
|
1554 | - } |
|
1555 | - $css .= "</style>"; |
|
1556 | - } |
|
1557 | - |
|
1558 | - return $css; |
|
1559 | - } |
|
1560 | - |
|
1561 | - /** |
|
1562 | - * Get an instance hash that will be unique to the type and settings. |
|
1563 | - * |
|
1564 | - * @since 1.0.20 |
|
1565 | - * @return string |
|
1566 | - */ |
|
1567 | - public function get_instance_hash(){ |
|
1568 | - $instance_string = $this->base_id . serialize( $this->instance ); |
|
1569 | - return hash( 'crc32b', $instance_string ); |
|
1570 | - } |
|
1571 | - |
|
1572 | - /** |
|
1573 | - * Get the conditional fields JavaScript. |
|
1574 | - * |
|
1575 | - * @return mixed |
|
1576 | - */ |
|
1577 | - public function conditional_fields_js() { |
|
1578 | - ob_start(); |
|
1579 | - ?> |
|
1384 | + } |
|
1385 | + |
|
1386 | + /** |
|
1387 | + * Convert an array of attributes to JS object or HTML attributes string. |
|
1388 | + * |
|
1389 | + * @todo there is prob a faster way to do this, also we could add some validation here. |
|
1390 | + * |
|
1391 | + * @param $attributes |
|
1392 | + * |
|
1393 | + * @return string |
|
1394 | + */ |
|
1395 | + public function array_to_attributes( $attributes, $html = false ) { |
|
1396 | + |
|
1397 | + if ( ! is_array( $attributes ) ) { |
|
1398 | + return ''; |
|
1399 | + } |
|
1400 | + |
|
1401 | + $output = ''; |
|
1402 | + foreach ( $attributes as $name => $value ) { |
|
1403 | + |
|
1404 | + if ( $html ) { |
|
1405 | + |
|
1406 | + if ( true === $value ) { |
|
1407 | + $output .= esc_html( $name ) . ' '; |
|
1408 | + } else if ( false !== $value ) { |
|
1409 | + $output .= sprintf( '%s="%s" ', esc_html( $name ), trim( esc_attr( $value ) ) ); |
|
1410 | + } |
|
1411 | + |
|
1412 | + } else { |
|
1413 | + $output .= sprintf( "'%s': '%s',", esc_js( $name ), is_bool( $value ) ? $value : trim( esc_js( $value ) ) ); |
|
1414 | + } |
|
1415 | + |
|
1416 | + } |
|
1417 | + |
|
1418 | + return $output; |
|
1419 | + } |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * Constructs id attributes for use in WP_Widget::form() fields. |
|
1423 | + * |
|
1424 | + * This function should be used in form() methods to create id attributes |
|
1425 | + * for fields to be saved by WP_Widget::update(). |
|
1426 | + * |
|
1427 | + * @since 2.8.0 |
|
1428 | + * @since 4.4.0 Array format field IDs are now accepted. |
|
1429 | + * |
|
1430 | + * @param string $field_name Field name. |
|
1431 | + * |
|
1432 | + * @return string ID attribute for `$field_name`. |
|
1433 | + */ |
|
1434 | + public function get_field_id( $field_name ) { |
|
1435 | + |
|
1436 | + $field_name = str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ); |
|
1437 | + $field_name = trim( $field_name, '-' ); |
|
1438 | + |
|
1439 | + return 'widget-' . $this->base_id . '-' . $this->get_number() . '-' . $field_name; |
|
1440 | + } |
|
1441 | + |
|
1442 | + /** |
|
1443 | + * Returns the instance number. |
|
1444 | + * |
|
1445 | + * @return int |
|
1446 | + */ |
|
1447 | + public function get_number() { |
|
1448 | + static $number = 1; |
|
1449 | + |
|
1450 | + if ( isset( $this->output_types['widget'] ) ) { |
|
1451 | + return $this->output_types['widget']->number; |
|
1452 | + } |
|
1453 | + |
|
1454 | + if ( empty( $this->number ) ) { |
|
1455 | + $this->number = $number; |
|
1456 | + $number ++; |
|
1457 | + } |
|
1458 | + |
|
1459 | + return $this->number; |
|
1460 | + } |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * Get the widget input title html. |
|
1464 | + * |
|
1465 | + * @param $args |
|
1466 | + * |
|
1467 | + * @return string |
|
1468 | + */ |
|
1469 | + public function widget_field_title( $args ) { |
|
1470 | + |
|
1471 | + $title = ''; |
|
1472 | + if ( isset( $args['title'] ) && $args['title'] ) { |
|
1473 | + if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
1474 | + $title = $this->get_widget_icon( $args['icon'], $args['title'] ); |
|
1475 | + } else { |
|
1476 | + $title = esc_attr($args['title']); |
|
1477 | + } |
|
1478 | + } |
|
1479 | + |
|
1480 | + return $title; |
|
1481 | + } |
|
1482 | + |
|
1483 | + /** |
|
1484 | + * Retrieves the icon to use for widgets / blocks. |
|
1485 | + * |
|
1486 | + * @return array |
|
1487 | + */ |
|
1488 | + public function get_widget_icon( $icon = 'box-top', $title = '' ) { |
|
1489 | + if($icon=='box-top'){ |
|
1490 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
1491 | + }elseif($icon=='box-right'){ |
|
1492 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
1493 | + }elseif($icon=='box-bottom'){ |
|
1494 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
1495 | + }elseif($icon=='box-left'){ |
|
1496 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
1497 | + } |
|
1498 | + } |
|
1499 | + |
|
1500 | + /** |
|
1501 | + * Constructs name attributes for use in form() fields |
|
1502 | + * |
|
1503 | + * This function should be used in form() methods to create name attributes for fields |
|
1504 | + * to be saved by update() |
|
1505 | + * |
|
1506 | + * @since 2.8.0 |
|
1507 | + * @since 4.4.0 Array format field names are now accepted. |
|
1508 | + * |
|
1509 | + * @param string $field_name Field name. |
|
1510 | + * |
|
1511 | + * @return string Name attribute for `$field_name`. |
|
1512 | + */ |
|
1513 | + public function get_field_name( $field_name ) { |
|
1514 | + $pos = strpos( $field_name, '[' ); |
|
1515 | + |
|
1516 | + if ( false !== $pos ) { |
|
1517 | + // Replace the first occurrence of '[' with ']['. |
|
1518 | + $field_name = '[' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); |
|
1519 | + } else { |
|
1520 | + $field_name = '[' . $field_name . ']'; |
|
1521 | + } |
|
1522 | + |
|
1523 | + return 'widget-' . $this->base_id . '[' . $this->get_number() . ']' . $field_name; |
|
1524 | + } |
|
1525 | + |
|
1526 | + public function widget_inputs_row_end($key, $args){ |
|
1527 | + if(!empty($args['row'])){ |
|
1528 | + // maybe close |
|
1529 | + if(!empty($args['row']['close'])){ |
|
1530 | + echo "</div></div>"; |
|
1531 | + } |
|
1532 | + |
|
1533 | + echo "</div>"; |
|
1534 | + } |
|
1535 | + } |
|
1536 | + |
|
1537 | + /** |
|
1538 | + * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
1539 | + * |
|
1540 | + * @param array $rules |
|
1541 | + * |
|
1542 | + * @since 1.0.20 |
|
1543 | + * @return string |
|
1544 | + */ |
|
1545 | + public function get_instance_style($rules = array()){ |
|
1546 | + $css = ''; |
|
1547 | + |
|
1548 | + if(!empty($rules)){ |
|
1549 | + $rules = array_unique($rules); |
|
1550 | + $instance_hash = $this->get_instance_hash(); |
|
1551 | + $css .= "<style>"; |
|
1552 | + foreach($rules as $rule){ |
|
1553 | + $css .= ".sdel-$instance_hash $rule"; |
|
1554 | + } |
|
1555 | + $css .= "</style>"; |
|
1556 | + } |
|
1557 | + |
|
1558 | + return $css; |
|
1559 | + } |
|
1560 | + |
|
1561 | + /** |
|
1562 | + * Get an instance hash that will be unique to the type and settings. |
|
1563 | + * |
|
1564 | + * @since 1.0.20 |
|
1565 | + * @return string |
|
1566 | + */ |
|
1567 | + public function get_instance_hash(){ |
|
1568 | + $instance_string = $this->base_id . serialize( $this->instance ); |
|
1569 | + return hash( 'crc32b', $instance_string ); |
|
1570 | + } |
|
1571 | + |
|
1572 | + /** |
|
1573 | + * Get the conditional fields JavaScript. |
|
1574 | + * |
|
1575 | + * @return mixed |
|
1576 | + */ |
|
1577 | + public function conditional_fields_js() { |
|
1578 | + ob_start(); |
|
1579 | + ?> |
|
1580 | 1580 | <script> |
1581 | 1581 | /** |
1582 | 1582 | * Conditional Fields |
@@ -2078,81 +2078,81 @@ discard block |
||
2078 | 2078 | <?php do_action( 'wp_super_duper_conditional_fields_js', $this ); ?> |
2079 | 2079 | </script> |
2080 | 2080 | <?php |
2081 | - $output = ob_get_clean(); |
|
2082 | - |
|
2083 | - return str_replace( array( '<script>', '</script>' ), '', trim( $output ) ); |
|
2084 | - } |
|
2085 | - |
|
2086 | - /** |
|
2087 | - * Output the super title. |
|
2088 | - * |
|
2089 | - * @param $args |
|
2090 | - * @param array $instance |
|
2091 | - * |
|
2092 | - * @return string |
|
2093 | - */ |
|
2094 | - public function output_title( $args, $instance = array() ) { |
|
2095 | - $output = ''; |
|
2096 | - |
|
2097 | - if ( ! empty( $instance['title'] ) ) { |
|
2098 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
2099 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->base_id ); |
|
2100 | - |
|
2101 | - if ( empty( $instance['widget_title_tag'] ) ) { |
|
2102 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
2103 | - } else { |
|
2104 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
2105 | - |
|
2106 | - // classes |
|
2107 | - $title_classes = array(); |
|
2108 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
2109 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
2110 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
2111 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
2112 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
2113 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
2114 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
2115 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
2116 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
2117 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
2118 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
2119 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
2120 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
2121 | - $title_classes = array_filter( $title_classes ); |
|
2122 | - |
|
2123 | - $class = ! empty( $title_classes ) ? implode( ' ', $title_classes ) : ''; |
|
2124 | - $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
2125 | - } |
|
2126 | - |
|
2127 | - } |
|
2128 | - |
|
2129 | - return $output; |
|
2130 | - } |
|
2081 | + $output = ob_get_clean(); |
|
2082 | + |
|
2083 | + return str_replace( array( '<script>', '</script>' ), '', trim( $output ) ); |
|
2084 | + } |
|
2085 | + |
|
2086 | + /** |
|
2087 | + * Output the super title. |
|
2088 | + * |
|
2089 | + * @param $args |
|
2090 | + * @param array $instance |
|
2091 | + * |
|
2092 | + * @return string |
|
2093 | + */ |
|
2094 | + public function output_title( $args, $instance = array() ) { |
|
2095 | + $output = ''; |
|
2096 | + |
|
2097 | + if ( ! empty( $instance['title'] ) ) { |
|
2098 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
2099 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->base_id ); |
|
2100 | + |
|
2101 | + if ( empty( $instance['widget_title_tag'] ) ) { |
|
2102 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
2103 | + } else { |
|
2104 | + $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
2105 | + |
|
2106 | + // classes |
|
2107 | + $title_classes = array(); |
|
2108 | + $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
2109 | + $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
2110 | + $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
2111 | + $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
2112 | + $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
2113 | + $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
2114 | + $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
2115 | + $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
2116 | + $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
2117 | + $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
2118 | + $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
2119 | + $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
2120 | + $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
2121 | + $title_classes = array_filter( $title_classes ); |
|
2122 | + |
|
2123 | + $class = ! empty( $title_classes ) ? implode( ' ', $title_classes ) : ''; |
|
2124 | + $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
2125 | + } |
|
2126 | + |
|
2127 | + } |
|
2128 | + |
|
2129 | + return $output; |
|
2130 | + } |
|
2131 | 2131 | |
2132 | - /** |
|
2133 | - * Backwards compatibility for SDv1 |
|
2134 | - * |
|
2135 | - * @param string $editor_id |
|
2136 | - * @param string $insert_shortcode_function |
|
2137 | - * |
|
2138 | - * @return string|void |
|
2139 | - */ |
|
2140 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
2141 | - return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_insert_button( $editor_id, $insert_shortcode_function ) : ''; |
|
2142 | - } |
|
2132 | + /** |
|
2133 | + * Backwards compatibility for SDv1 |
|
2134 | + * |
|
2135 | + * @param string $editor_id |
|
2136 | + * @param string $insert_shortcode_function |
|
2137 | + * |
|
2138 | + * @return string|void |
|
2139 | + */ |
|
2140 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
2141 | + return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_insert_button( $editor_id, $insert_shortcode_function ) : ''; |
|
2142 | + } |
|
2143 | 2143 | |
2144 | - /** |
|
2145 | - * Backwards compatibility for SDv1 |
|
2146 | - * |
|
2147 | - * @param string $id |
|
2148 | - * @param string $search_for_id |
|
2149 | - * |
|
2150 | - * @return mixed|string |
|
2151 | - */ |
|
2152 | - public static function shortcode_button( $id = '', $search_for_id = '') { |
|
2153 | - return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_button( $id, $search_for_id ) : ''; |
|
2154 | - } |
|
2155 | - |
|
2156 | - } |
|
2144 | + /** |
|
2145 | + * Backwards compatibility for SDv1 |
|
2146 | + * |
|
2147 | + * @param string $id |
|
2148 | + * @param string $search_for_id |
|
2149 | + * |
|
2150 | + * @return mixed|string |
|
2151 | + */ |
|
2152 | + public static function shortcode_button( $id = '', $search_for_id = '') { |
|
2153 | + return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_button( $id, $search_for_id ) : ''; |
|
2154 | + } |
|
2155 | + |
|
2156 | + } |
|
2157 | 2157 | |
2158 | 2158 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | * @since 1.0.0 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | // Ensure the class is only loaded once. |
11 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
11 | +if (!class_exists('WP_Super_Duper')) { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * |
@@ -51,36 +51,36 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Take the array options and use them to build. |
53 | 53 | */ |
54 | - public function __construct( $options ) { |
|
54 | + public function __construct($options) { |
|
55 | 55 | global $sd_widgets; |
56 | 56 | |
57 | - $sd_widgets[ $options['base_id'] ] = array( |
|
57 | + $sd_widgets[$options['base_id']] = array( |
|
58 | 58 | 'name' => $options['name'], |
59 | 59 | 'class_name' => $options['class_name'] |
60 | 60 | ); |
61 | - $this->base_id = $options['base_id']; |
|
61 | + $this->base_id = $options['base_id']; |
|
62 | 62 | |
63 | 63 | // Lets filter the options before we do anything. |
64 | - $options = apply_filters( 'wp_super_duper_options', $options, $this ); |
|
65 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options, $this ); |
|
66 | - $options = $this->add_name_from_key( $options ); |
|
64 | + $options = apply_filters('wp_super_duper_options', $options, $this); |
|
65 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options, $this); |
|
66 | + $options = $this->add_name_from_key($options); |
|
67 | 67 | |
68 | 68 | // Set args. |
69 | 69 | $this->options = $options; |
70 | 70 | $this->base_id = $options['base_id']; |
71 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
71 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
72 | 72 | |
73 | 73 | // Load output types. |
74 | 74 | $this->load_output_types(); |
75 | 75 | |
76 | 76 | // add generator text to admin head |
77 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
77 | + add_action('admin_head', array($this, 'generator')); |
|
78 | 78 | |
79 | - add_action( 'admin_init', array( __CLASS__, 'load_widgets_setting' ) ); |
|
79 | + add_action('admin_init', array(__CLASS__, 'load_widgets_setting')); |
|
80 | 80 | |
81 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
81 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
82 | 82 | |
83 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
83 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - protected function add_name_from_key( $options, $arguments = false ) { |
|
96 | - if ( ! empty( $options['arguments'] ) ) { |
|
97 | - foreach ( $options['arguments'] as $key => $val ) { |
|
98 | - $options['arguments'][ $key ]['name'] = $key; |
|
95 | + protected function add_name_from_key($options, $arguments = false) { |
|
96 | + if (!empty($options['arguments'])) { |
|
97 | + foreach ($options['arguments'] as $key => $val) { |
|
98 | + $options['arguments'][$key]['name'] = $key; |
|
99 | 99 | } |
100 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
101 | - foreach ( $options as $key => $val ) { |
|
102 | - $options[ $key ]['name'] = $key; |
|
100 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
101 | + foreach ($options as $key => $val) { |
|
102 | + $options[$key]['name'] = $key; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -112,39 +112,39 @@ discard block |
||
112 | 112 | public function load_output_types() { |
113 | 113 | |
114 | 114 | $allowed_types = $this->get_output_types(); |
115 | - $output_types = array( 'block', 'shortcode', 'widget' ); |
|
115 | + $output_types = array('block', 'shortcode', 'widget'); |
|
116 | 116 | |
117 | 117 | // Check if this is being overidden by the widget. |
118 | 118 | $args = $this->get_arguments(); |
119 | - if ( isset( $args['output_types'] ) && is_array( $args['output_types'] ) ) { |
|
120 | - $output_types = $args['output_types'] ; |
|
119 | + if (isset($args['output_types']) && is_array($args['output_types'])) { |
|
120 | + $output_types = $args['output_types']; |
|
121 | 121 | } |
122 | 122 | |
123 | - if ( isset( $this->options['output_types'] ) && is_array( $this->options['output_types'] ) ) { |
|
124 | - $output_types = $this->options['output_types'] ; |
|
123 | + if (isset($this->options['output_types']) && is_array($this->options['output_types'])) { |
|
124 | + $output_types = $this->options['output_types']; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // Load each output type. |
128 | - foreach ( $output_types as $output_type ) { |
|
128 | + foreach ($output_types as $output_type) { |
|
129 | 129 | |
130 | 130 | // Ensure this is an allowed type. |
131 | - if ( ! isset( $allowed_types[ $output_type ] ) ) { |
|
131 | + if (!isset($allowed_types[$output_type])) { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | |
135 | 135 | // If the class does not exist, try loading it. |
136 | - if ( ! class_exists( $allowed_types[ $output_type ] ) ) { |
|
136 | + if (!class_exists($allowed_types[$output_type])) { |
|
137 | 137 | |
138 | - if ( file_exists( plugin_dir_path( __FILE__ ) . "type/$output_type.php" ) ) { |
|
139 | - require_once( plugin_dir_path( __FILE__ ) . "type/$output_type.php" ); |
|
138 | + if (file_exists(plugin_dir_path(__FILE__) . "type/$output_type.php")) { |
|
139 | + require_once(plugin_dir_path(__FILE__) . "type/$output_type.php"); |
|
140 | 140 | } else { |
141 | 141 | continue; |
142 | 142 | } |
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - $output_class = $allowed_types[ $output_type ]; |
|
147 | - $this->output_types[ $output_type ] = new $output_class( $this ); |
|
146 | + $output_class = $allowed_types[$output_type]; |
|
147 | + $this->output_types[$output_type] = new $output_class($this); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | ); |
165 | 165 | |
166 | 166 | // Maybe disable widgets. |
167 | - $disable_widget = get_option( 'sd_load_widgets', 'auto' ); |
|
167 | + $disable_widget = get_option('sd_load_widgets', 'auto'); |
|
168 | 168 | |
169 | - if ( 'auto' === $disable_widget ) { |
|
170 | - if ( !$this->widgets_required() ) { |
|
171 | - unset( $types['widget'] ); |
|
169 | + if ('auto' === $disable_widget) { |
|
170 | + if (!$this->widgets_required()) { |
|
171 | + unset($types['widget']); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | - if ( 'no' === $disable_widget ) { |
|
176 | - unset( $types['widget'] ); |
|
175 | + if ('no' === $disable_widget) { |
|
176 | + unset($types['widget']); |
|
177 | 177 | } |
178 | 178 | |
179 | - return apply_filters( 'super_duper_types', $types, $this ); |
|
179 | + return apply_filters('super_duper_types', $types, $this); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -184,39 +184,39 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return mixed|void |
186 | 186 | */ |
187 | - protected function widgets_required(){ |
|
187 | + protected function widgets_required() { |
|
188 | 188 | global $wp_version; |
189 | 189 | |
190 | 190 | $required = false; |
191 | 191 | |
192 | 192 | |
193 | 193 | // check wp version |
194 | - if( version_compare( $wp_version, '5.8', '<' ) ){ |
|
194 | + if (version_compare($wp_version, '5.8', '<')) { |
|
195 | 195 | $required = true; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Page builders that require widgets |
199 | - if( |
|
199 | + if ( |
|
200 | 200 | !$required && ( |
201 | - defined( 'ELEMENTOR_VERSION' ) // elementor |
|
202 | - || class_exists( 'Fusion_Element' ) // Fusion Builder (avada) |
|
203 | - || class_exists( 'SiteOrigin_Panels' ) // SiteOrigin Page builder |
|
204 | - || defined( 'WPB_VC_VERSION' ) // WPBakery page builder |
|
205 | - || defined( 'CT_VERSION' ) // Oxygen Builder |
|
206 | - || defined( 'FL_BUILDER_VERSION' ) // Beaver Builder |
|
207 | - || defined( 'FL_THEME_BUILDER_VERSION' ) // Beaver Themer |
|
201 | + defined('ELEMENTOR_VERSION') // elementor |
|
202 | + || class_exists('Fusion_Element') // Fusion Builder (avada) |
|
203 | + || class_exists('SiteOrigin_Panels') // SiteOrigin Page builder |
|
204 | + || defined('WPB_VC_VERSION') // WPBakery page builder |
|
205 | + || defined('CT_VERSION') // Oxygen Builder |
|
206 | + || defined('FL_BUILDER_VERSION') // Beaver Builder |
|
207 | + || defined('FL_THEME_BUILDER_VERSION') // Beaver Themer |
|
208 | 208 | ) |
209 | - ){ |
|
209 | + ) { |
|
210 | 210 | $required = true; |
211 | 211 | } |
212 | 212 | |
213 | 213 | // Theme has active widgets |
214 | - if( !$required && !empty( $this->has_active_widgets() ) ){ |
|
214 | + if (!$required && !empty($this->has_active_widgets())) { |
|
215 | 215 | $required = true; |
216 | 216 | } |
217 | 217 | |
218 | 218 | |
219 | - return apply_filters( 'sd_widgets_required' , $required ); |
|
219 | + return apply_filters('sd_widgets_required', $required); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -224,28 +224,28 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return bool |
226 | 226 | */ |
227 | - protected function has_active_widgets(){ |
|
227 | + protected function has_active_widgets() { |
|
228 | 228 | global $sd_has_active_widgets; |
229 | 229 | |
230 | 230 | // have we already done this? |
231 | - if(!is_null($sd_has_active_widgets)){ |
|
231 | + if (!is_null($sd_has_active_widgets)) { |
|
232 | 232 | return $sd_has_active_widgets; |
233 | 233 | } |
234 | 234 | |
235 | 235 | $result = false; |
236 | 236 | $sidebars_widgets = get_option('sidebars_widgets'); |
237 | 237 | |
238 | - if(is_array($sidebars_widgets)){ |
|
238 | + if (is_array($sidebars_widgets)) { |
|
239 | 239 | |
240 | 240 | foreach ($sidebars_widgets as $key => $value) { |
241 | 241 | |
242 | 242 | |
243 | 243 | |
244 | - if( $key != 'wp_inactive_widgets' ) { |
|
244 | + if ($key != 'wp_inactive_widgets') { |
|
245 | 245 | |
246 | - if(!empty($value) && is_array($value)){ |
|
247 | - foreach($value as $widget){ |
|
248 | - if($widget && substr( $widget, 0, 6 ) !== "block-"){ |
|
246 | + if (!empty($value) && is_array($value)) { |
|
247 | + foreach ($value as $widget) { |
|
248 | + if ($widget && substr($widget, 0, 6) !== "block-") { |
|
249 | 249 | $result = true; |
250 | 250 | } |
251 | 251 | } |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @return array Get arguments. |
269 | 269 | */ |
270 | 270 | public function get_arguments() { |
271 | - if ( empty( $this->arguments ) ) { |
|
271 | + if (empty($this->arguments)) { |
|
272 | 272 | $this->arguments = $this->set_arguments(); |
273 | 273 | } |
274 | 274 | |
275 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
276 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
275 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
276 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
277 | 277 | |
278 | 278 | return $this->arguments; |
279 | 279 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | jQuery($this).data('sd-widget-enabled', true); |
345 | 345 | } |
346 | 346 | |
347 | - 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>'; |
|
347 | + 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>'; |
|
348 | 348 | var form = jQuery($this).parents('' + $selector + ''); |
349 | 349 | |
350 | 350 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -380,10 +380,10 @@ discard block |
||
380 | 380 | /* |
381 | 381 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
382 | 382 | */ |
383 | - return str_replace( array( |
|
383 | + return str_replace(array( |
|
384 | 384 | '<script>', |
385 | 385 | '</script>' |
386 | - ), '', $output ); |
|
386 | + ), '', $output); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,12 +393,12 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public static function get_picker( $editor_id = '' ) { |
|
396 | + public static function get_picker($editor_id = '') { |
|
397 | 397 | |
398 | 398 | ob_start(); |
399 | - if ( isset( $_POST['editor_id'] ) ) { |
|
400 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
401 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
399 | + if (isset($_POST['editor_id'])) { |
|
400 | + $editor_id = esc_attr($_POST['editor_id']); |
|
401 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
402 | 402 | $editor_id = 'main_content_content_vb_tiny_mce'; |
403 | 403 | } |
404 | 404 | |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | |
408 | 408 | <div class="sd-shortcode-left-wrap"> |
409 | 409 | <?php |
410 | - ksort( $sd_widgets ); |
|
410 | + ksort($sd_widgets); |
|
411 | 411 | // print_r($sd_widgets);exit; |
412 | - if ( ! empty( $sd_widgets ) ) { |
|
412 | + if (!empty($sd_widgets)) { |
|
413 | 413 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
414 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
415 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
416 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
414 | + echo "<option>" . __('Select shortcode') . "</option>"; |
|
415 | + foreach ($sd_widgets as $shortcode => $class) { |
|
416 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
417 | 417 | } |
418 | 418 | echo "</select>"; |
419 | 419 | |
@@ -426,37 +426,37 @@ discard block |
||
426 | 426 | <div class="sd-shortcode-right-wrap"> |
427 | 427 | <textarea id='sd-shortcode-output' disabled></textarea> |
428 | 428 | <div id='sd-shortcode-output-actions'> |
429 | - <?php if ( $editor_id != '' ) { ?> |
|
429 | + <?php if ($editor_id != '') { ?> |
|
430 | 430 | <button class="button sd-insert-shortcode-button" |
431 | - onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
|
431 | + onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { |
|
432 | 432 | echo "'" . $editor_id . "'"; |
433 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
433 | + } ?>)"><?php _e('Insert shortcode'); ?></button> |
|
434 | 434 | <?php } ?> |
435 | 435 | <button class="button" |
436 | - onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
|
436 | + onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button> |
|
437 | 437 | </div> |
438 | 438 | </div> |
439 | 439 | <?php |
440 | 440 | |
441 | 441 | $html = ob_get_clean(); |
442 | 442 | |
443 | - if ( wp_doing_ajax() ) { |
|
443 | + if (wp_doing_ajax()) { |
|
444 | 444 | echo $html; |
445 | 445 | $should_die = true; |
446 | 446 | |
447 | 447 | // some builder get the editor via ajax so we should not die on those occasions |
448 | 448 | $dont_die = array( |
449 | - 'parent_tag',// WP Bakery |
|
449 | + 'parent_tag', // WP Bakery |
|
450 | 450 | 'avia_request' // enfold |
451 | 451 | ); |
452 | 452 | |
453 | - foreach ( $dont_die as $request ) { |
|
454 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
453 | + foreach ($dont_die as $request) { |
|
454 | + if (isset($_REQUEST[$request])) { |
|
455 | 455 | $should_die = false; |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | - if ( $should_die ) { |
|
459 | + if ($should_die) { |
|
460 | 460 | wp_die(); |
461 | 461 | } |
462 | 462 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | jQuery($this).data('sd-widget-enabled', true); |
536 | 536 | } |
537 | 537 | |
538 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
538 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
539 | 539 | var form = jQuery($this).parents('' + $selector + ''); |
540 | 540 | |
541 | 541 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | }); |
630 | 630 | |
631 | 631 | } |
632 | - <?php do_action( 'wp_super_duper_widget_js' ); ?> |
|
632 | + <?php do_action('wp_super_duper_widget_js'); ?> |
|
633 | 633 | </script> |
634 | 634 | |
635 | 635 | <?php |
@@ -639,10 +639,10 @@ discard block |
||
639 | 639 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
640 | 640 | */ |
641 | 641 | |
642 | - return str_replace( array( |
|
642 | + return str_replace(array( |
|
643 | 643 | '<script>', |
644 | 644 | '</script>' |
645 | - ), '', $output ); |
|
645 | + ), '', $output); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /** |
@@ -652,12 +652,12 @@ discard block |
||
652 | 652 | * |
653 | 653 | * @return mixed |
654 | 654 | */ |
655 | - public static function widget_css( $advanced = true ) { |
|
655 | + public static function widget_css($advanced = true) { |
|
656 | 656 | ob_start(); |
657 | 657 | ?> |
658 | 658 | |
659 | 659 | <style> |
660 | - <?php if ( $advanced ) : ?> |
|
660 | + <?php if ($advanced) : ?> |
|
661 | 661 | .sd-advanced-setting { |
662 | 662 | display: none; |
663 | 663 | } |
@@ -701,21 +701,21 @@ discard block |
||
701 | 701 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
702 | 702 | */ |
703 | 703 | |
704 | - return str_replace( array( |
|
704 | + return str_replace(array( |
|
705 | 705 | '<style>', |
706 | 706 | '</style>' |
707 | - ), '', $output ); |
|
707 | + ), '', $output); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Registers the widgets loading settings. |
712 | 712 | */ |
713 | 713 | public static function load_widgets_setting() { |
714 | - register_setting( 'general', 'sd_load_widgets', 'esc_attr' ); |
|
714 | + register_setting('general', 'sd_load_widgets', 'esc_attr'); |
|
715 | 715 | |
716 | 716 | add_settings_field( |
717 | 717 | 'sd_load_widgets', |
718 | - '<label for="sd_load_widgets">' . __( 'Load Super Duper Widgets' ) . '</label>', |
|
718 | + '<label for="sd_load_widgets">' . __('Load Super Duper Widgets') . '</label>', |
|
719 | 719 | 'WP_Super_Duper::load_widgets_setting_html', |
720 | 720 | 'general' |
721 | 721 | ); |
@@ -727,26 +727,26 @@ discard block |
||
727 | 727 | */ |
728 | 728 | public static function load_widgets_setting_html() { |
729 | 729 | $available_options = array( |
730 | - 'yes' => __( 'Yes' ), |
|
731 | - 'no' => __( 'No' ), |
|
732 | - 'auto' => __( 'Auto' ), |
|
730 | + 'yes' => __('Yes'), |
|
731 | + 'no' => __('No'), |
|
732 | + 'auto' => __('Auto'), |
|
733 | 733 | ); |
734 | - $selected_option = get_option( 'sd_load_widgets', 'auto' ); |
|
734 | + $selected_option = get_option('sd_load_widgets', 'auto'); |
|
735 | 735 | |
736 | 736 | ?> |
737 | 737 | <select name="sd_load_widgets" id="sd_load_widgets"> |
738 | - <?php foreach ( $available_options as $key => $label ) : ?> |
|
739 | - <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $selected_option ); ?>><?php echo esc_html( $label ); ?></option> |
|
738 | + <?php foreach ($available_options as $key => $label) : ?> |
|
739 | + <option value="<?php echo esc_attr($key); ?>" <?php selected($key, $selected_option); ?>><?php echo esc_html($label); ?></option> |
|
740 | 740 | <?php endforeach; ?> |
741 | 741 | </select> |
742 | - <p class="description"><?php _e( 'This option allows you to disable Super Duper widgets and instead only load the blocks and shortcodes.' ); ?></p> |
|
742 | + <p class="description"><?php _e('This option allows you to disable Super Duper widgets and instead only load the blocks and shortcodes.'); ?></p> |
|
743 | 743 | <?php |
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
747 | 747 | * prevent SDv1 errors if register_widget() function used |
748 | 748 | */ |
749 | - public function _register(){ |
|
749 | + public function _register() { |
|
750 | 750 | // backwards compatibility |
751 | 751 | } |
752 | 752 | |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | public function generator() { |
757 | 757 | |
758 | 758 | // We want to set this once. |
759 | - if ( empty( $GLOBALS['SD_SET_GENERATOR'] ) ) { |
|
759 | + if (empty($GLOBALS['SD_SET_GENERATOR'])) { |
|
760 | 760 | echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
761 | 761 | $GLOBALS['SD_SET_GENERATOR'] = 1; |
762 | 762 | } |
@@ -770,8 +770,8 @@ discard block |
||
770 | 770 | * @param array $widget_args |
771 | 771 | * @param string $content |
772 | 772 | */ |
773 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
774 | - echo call_user_func( $this->options['widget_ops']['output'], $args, $widget_args, $content ); |
|
773 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
774 | + echo call_user_func($this->options['widget_ops']['output'], $args, $widget_args, $content); |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | /** |
@@ -781,8 +781,8 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public function preview_placeholder_text( $name = '' ) { |
|
785 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
784 | + public function preview_placeholder_text($name = '') { |
|
785 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>"; |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -792,13 +792,13 @@ discard block |
||
792 | 792 | * |
793 | 793 | * @return mixed |
794 | 794 | */ |
795 | - public function string_to_bool( $options ) { |
|
795 | + public function string_to_bool($options) { |
|
796 | 796 | // convert bool strings to booleans |
797 | - foreach ( $options as $key => $val ) { |
|
798 | - if ( $val == 'false' ) { |
|
799 | - $options[ $key ] = false; |
|
800 | - } elseif ( $val == 'true' ) { |
|
801 | - $options[ $key ] = true; |
|
797 | + foreach ($options as $key => $val) { |
|
798 | + if ($val == 'false') { |
|
799 | + $options[$key] = false; |
|
800 | + } elseif ($val == 'true') { |
|
801 | + $options[$key] = true; |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
@@ -814,26 +814,26 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @return array |
816 | 816 | */ |
817 | - public function argument_values( $instance ) { |
|
817 | + public function argument_values($instance) { |
|
818 | 818 | $argument_values = array(); |
819 | 819 | |
820 | 820 | // set widget instance |
821 | 821 | $this->instance = $instance; |
822 | 822 | |
823 | - if ( empty( $this->arguments ) ) { |
|
823 | + if (empty($this->arguments)) { |
|
824 | 824 | $this->arguments = $this->get_arguments(); |
825 | 825 | } |
826 | 826 | |
827 | - if ( ! empty( $this->arguments ) ) { |
|
828 | - foreach ( $this->arguments as $key => $args ) { |
|
827 | + if (!empty($this->arguments)) { |
|
828 | + foreach ($this->arguments as $key => $args) { |
|
829 | 829 | // set the input name from the key |
830 | 830 | $args['name'] = $key; |
831 | 831 | // |
832 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
833 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
832 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
833 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
834 | 834 | // don't set default for an empty checkbox |
835 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
836 | - $argument_values[ $key ] = $args['default']; |
|
835 | + } elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
836 | + $argument_values[$key] = $args['default']; |
|
837 | 837 | } |
838 | 838 | } |
839 | 839 | } |
@@ -849,15 +849,15 @@ discard block |
||
849 | 849 | public function get_url() { |
850 | 850 | $url = $this->url; |
851 | 851 | |
852 | - if ( ! $url ) { |
|
852 | + if (!$url) { |
|
853 | 853 | // check if we are inside a plugin |
854 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
854 | + $file_dir = str_replace("/includes", "", dirname(__FILE__)); |
|
855 | 855 | |
856 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
857 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
856 | + $dir_parts = explode("/wp-content/", $file_dir); |
|
857 | + $url_parts = explode("/wp-content/", plugins_url()); |
|
858 | 858 | |
859 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
860 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
859 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
860 | + $url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]); |
|
861 | 861 | $this->url = $url; |
862 | 862 | } |
863 | 863 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | */ |
884 | 884 | public function is_divi_preview() { |
885 | 885 | $result = false; |
886 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
886 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
887 | 887 | $result = true; |
888 | 888 | } |
889 | 889 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | */ |
899 | 899 | public function is_elementor_preview() { |
900 | 900 | $result = false; |
901 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
901 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
902 | 902 | $result = true; |
903 | 903 | } |
904 | 904 | |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | */ |
914 | 914 | public function is_beaver_preview() { |
915 | 915 | $result = false; |
916 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
916 | + if (isset($_REQUEST['fl_builder'])) { |
|
917 | 917 | $result = true; |
918 | 918 | } |
919 | 919 | |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | */ |
929 | 929 | public function is_siteorigin_preview() { |
930 | 930 | $result = false; |
931 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
931 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
932 | 932 | $result = true; |
933 | 933 | } |
934 | 934 | |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | */ |
944 | 944 | public function is_cornerstone_preview() { |
945 | 945 | $result = false; |
946 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
946 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
947 | 947 | $result = true; |
948 | 948 | } |
949 | 949 | |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | */ |
959 | 959 | public function is_fusion_preview() { |
960 | 960 | $result = false; |
961 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
961 | + if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) { |
|
962 | 962 | $result = true; |
963 | 963 | } |
964 | 964 | |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | */ |
974 | 974 | public function is_oxygen_preview() { |
975 | 975 | $result = false; |
976 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
976 | + if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) { |
|
977 | 977 | $result = true; |
978 | 978 | } |
979 | 979 | |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | */ |
991 | 991 | public function is_block_content_call() { |
992 | 992 | $result = false; |
993 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
993 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
994 | 994 | $result = true; |
995 | 995 | } |
996 | 996 | |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | * |
1003 | 1003 | * @param array $instance The widget options. |
1004 | 1004 | */ |
1005 | - public function form( $instance ) { |
|
1005 | + public function form($instance) { |
|
1006 | 1006 | |
1007 | 1007 | // Set widget instance. |
1008 | 1008 | $this->instance = $instance; |
@@ -1011,45 +1011,45 @@ discard block |
||
1011 | 1011 | echo $this->widget_advanced_toggle(); |
1012 | 1012 | |
1013 | 1013 | // Display description. |
1014 | - printf( '<p>%s</p>', esc_html( $this->options['widget_ops']['description'] ) ); |
|
1014 | + printf('<p>%s</p>', esc_html($this->options['widget_ops']['description'])); |
|
1015 | 1015 | |
1016 | 1016 | // Prepare arguments. |
1017 | 1017 | $arguments_raw = $this->get_arguments(); |
1018 | 1018 | |
1019 | - if ( is_array( $arguments_raw ) ) { |
|
1019 | + if (is_array($arguments_raw)) { |
|
1020 | 1020 | |
1021 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
1021 | + $arguments = $this->group_arguments($arguments_raw); |
|
1022 | 1022 | |
1023 | 1023 | // Do we have sections? |
1024 | - if ( $arguments != $arguments_raw ) { |
|
1024 | + if ($arguments != $arguments_raw) { |
|
1025 | 1025 | |
1026 | 1026 | $panel_count = 0; |
1027 | - foreach ( $arguments as $key => $args ) { |
|
1027 | + foreach ($arguments as $key => $args) { |
|
1028 | 1028 | |
1029 | 1029 | $hide = $panel_count ? ' style="display:none;" ' : ''; |
1030 | 1030 | $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
1031 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . esc_attr( $icon_class ) . "'></i></button>"; |
|
1032 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
1031 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . esc_attr($icon_class) . "'></i></button>"; |
|
1032 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>"; |
|
1033 | 1033 | |
1034 | - foreach ( $args as $k => $a ) { |
|
1034 | + foreach ($args as $k => $a) { |
|
1035 | 1035 | |
1036 | 1036 | $this->widget_inputs_row_start($k, $a); |
1037 | - $this->widget_inputs( $a, $instance ); |
|
1037 | + $this->widget_inputs($a, $instance); |
|
1038 | 1038 | $this->widget_inputs_row_end($k, $a); |
1039 | 1039 | |
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | echo "</div>"; |
1043 | 1043 | |
1044 | - $panel_count ++; |
|
1044 | + $panel_count++; |
|
1045 | 1045 | |
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | } else { |
1049 | 1049 | |
1050 | - foreach ( $arguments as $key => $args ) { |
|
1050 | + foreach ($arguments as $key => $args) { |
|
1051 | 1051 | $this->widget_inputs_row_start($key, $args); |
1052 | - $this->widget_inputs( $args, $instance ); |
|
1052 | + $this->widget_inputs($args, $instance); |
|
1053 | 1053 | $this->widget_inputs_row_end($key, $args); |
1054 | 1054 | } |
1055 | 1055 | |
@@ -1081,9 +1081,9 @@ discard block |
||
1081 | 1081 | $show = false; |
1082 | 1082 | $arguments = $this->get_arguments(); |
1083 | 1083 | |
1084 | - if ( ! empty( $arguments ) ) { |
|
1085 | - foreach ( $arguments as $argument ) { |
|
1086 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
1084 | + if (!empty($arguments)) { |
|
1085 | + foreach ($arguments as $argument) { |
|
1086 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
1087 | 1087 | $show = true; |
1088 | 1088 | break; // no need to continue if we know we have it |
1089 | 1089 | } |
@@ -1100,23 +1100,23 @@ discard block |
||
1100 | 1100 | * |
1101 | 1101 | * @return array |
1102 | 1102 | */ |
1103 | - public function group_arguments( $arguments ) { |
|
1103 | + public function group_arguments($arguments) { |
|
1104 | 1104 | |
1105 | - if ( ! empty( $arguments ) ) { |
|
1105 | + if (!empty($arguments)) { |
|
1106 | 1106 | $temp_arguments = array(); |
1107 | - $general = __( "General" ); |
|
1107 | + $general = __("General"); |
|
1108 | 1108 | $add_sections = false; |
1109 | - foreach ( $arguments as $key => $args ) { |
|
1110 | - if ( isset( $args['group'] ) ) { |
|
1111 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
1109 | + foreach ($arguments as $key => $args) { |
|
1110 | + if (isset($args['group'])) { |
|
1111 | + $temp_arguments[$args['group']][$key] = $args; |
|
1112 | 1112 | $add_sections = true; |
1113 | 1113 | } else { |
1114 | - $temp_arguments[ $general ][ $key ] = $args; |
|
1114 | + $temp_arguments[$general][$key] = $args; |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | // only add sections if more than one |
1119 | - if ( $add_sections ) { |
|
1119 | + if ($add_sections) { |
|
1120 | 1120 | $arguments = $temp_arguments; |
1121 | 1121 | } |
1122 | 1122 | } |
@@ -1124,23 +1124,23 @@ discard block |
||
1124 | 1124 | return $arguments; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - public function widget_inputs_row_start($key, $args){ |
|
1128 | - if(!empty($args['row'])){ |
|
1127 | + public function widget_inputs_row_start($key, $args) { |
|
1128 | + if (!empty($args['row'])) { |
|
1129 | 1129 | // maybe open |
1130 | - if(!empty($args['row']['open'])){ |
|
1130 | + if (!empty($args['row']['open'])) { |
|
1131 | 1131 | ?> |
1132 | - <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
|
1133 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
1132 | + <div class='bsui sd-argument ' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php if (!empty($args['row']['element_require'])) { |
|
1133 | + echo $this->convert_element_require($args['row']['element_require']); |
|
1134 | 1134 | } ?>'> |
1135 | - <?php if(!empty($args['row']['title'])){ ?> |
|
1136 | - <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
|
1135 | + <?php if (!empty($args['row']['title'])) { ?> |
|
1136 | + <label class="mb-0 "><?php echo esc_attr($args['row']['title']); ?><?php echo $this->widget_field_desc($args['row']); ?></label> |
|
1137 | 1137 | <?php }?> |
1138 | - <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
|
1138 | + <div class='row <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>'> |
|
1139 | 1139 | <div class='col pr-2'> |
1140 | 1140 | <?php |
1141 | - }elseif(!empty($args['row']['close'])){ |
|
1141 | + }elseif (!empty($args['row']['close'])) { |
|
1142 | 1142 | echo "<div class='col pl-0'>"; |
1143 | - }else{ |
|
1143 | + } else { |
|
1144 | 1144 | echo "<div class='col pl-0 pr-2'>"; |
1145 | 1145 | } |
1146 | 1146 | } |
@@ -1155,14 +1155,14 @@ discard block |
||
1155 | 1155 | * |
1156 | 1156 | * @return string $output |
1157 | 1157 | */ |
1158 | - public function convert_element_require( $input ) { |
|
1158 | + public function convert_element_require($input) { |
|
1159 | 1159 | |
1160 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
1160 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
1161 | 1161 | |
1162 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
1162 | + $output = esc_attr(str_replace(array("[%", "%]"), array( |
|
1163 | 1163 | "jQuery(form).find('[data-argument=\"", |
1164 | 1164 | "\"]').find('input,select,textarea').val()" |
1165 | - ), $input ) ); |
|
1165 | + ), $input)); |
|
1166 | 1166 | |
1167 | 1167 | return $output; |
1168 | 1168 | } |
@@ -1175,14 +1175,14 @@ discard block |
||
1175 | 1175 | * @return string |
1176 | 1176 | * @todo, need to make its own tooltip script |
1177 | 1177 | */ |
1178 | - public function widget_field_desc( $args ) { |
|
1178 | + public function widget_field_desc($args) { |
|
1179 | 1179 | |
1180 | 1180 | $description = ''; |
1181 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
1182 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
1183 | - $description = $this->desc_tip( $args['desc'] ); |
|
1181 | + if (isset($args['desc']) && $args['desc']) { |
|
1182 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
1183 | + $description = $this->desc_tip($args['desc']); |
|
1184 | 1184 | } else { |
1185 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
1185 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
1186 | 1186 | } |
1187 | 1187 | } |
1188 | 1188 | |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | * |
1198 | 1198 | * @return string |
1199 | 1199 | */ |
1200 | - public function desc_tip( $tip, $allow_html = false ) { |
|
1201 | - if ( $allow_html ) { |
|
1202 | - $tip = $this->sanitize_tooltip( $tip ); |
|
1200 | + public function desc_tip($tip, $allow_html = false) { |
|
1201 | + if ($allow_html) { |
|
1202 | + $tip = $this->sanitize_tooltip($tip); |
|
1203 | 1203 | } else { |
1204 | - $tip = esc_attr( $tip ); |
|
1204 | + $tip = esc_attr($tip); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -1214,8 +1214,8 @@ discard block |
||
1214 | 1214 | * |
1215 | 1215 | * @return string |
1216 | 1216 | */ |
1217 | - public function sanitize_tooltip( $var ) { |
|
1218 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
1217 | + public function sanitize_tooltip($var) { |
|
1218 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
1219 | 1219 | 'br' => array(), |
1220 | 1220 | 'em' => array(), |
1221 | 1221 | 'strong' => array(), |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | 'li' => array(), |
1226 | 1226 | 'ol' => array(), |
1227 | 1227 | 'p' => array(), |
1228 | - ) ) ); |
|
1228 | + ))); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | /** |
@@ -1234,56 +1234,56 @@ discard block |
||
1234 | 1234 | * @param $args |
1235 | 1235 | * @param $instance |
1236 | 1236 | */ |
1237 | - public function widget_inputs( $args, $instance ) { |
|
1237 | + public function widget_inputs($args, $instance) { |
|
1238 | 1238 | |
1239 | 1239 | $class = ""; |
1240 | 1240 | $element_require = ""; |
1241 | 1241 | $custom_attributes = ""; |
1242 | 1242 | |
1243 | 1243 | // get value |
1244 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
1245 | - $value = $instance[ $args['name'] ]; |
|
1246 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
1247 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
1244 | + if (isset($instance[$args['name']])) { |
|
1245 | + $value = $instance[$args['name']]; |
|
1246 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
1247 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
1248 | 1248 | } else { |
1249 | 1249 | $value = ''; |
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | // get placeholder |
1253 | - if ( ! empty( $args['placeholder'] ) ) { |
|
1254 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
1253 | + if (!empty($args['placeholder'])) { |
|
1254 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
1255 | 1255 | } else { |
1256 | 1256 | $placeholder = ''; |
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | // get if advanced |
1260 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
1260 | + if (isset($args['advanced']) && $args['advanced']) { |
|
1261 | 1261 | $class .= " sd-advanced-setting "; |
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | // element_require |
1265 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
1265 | + if (isset($args['element_require']) && $args['element_require']) { |
|
1266 | 1266 | $element_require = $args['element_require']; |
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | // custom_attributes |
1270 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
1271 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
1270 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
1271 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | // before wrapper |
1276 | 1276 | ?> |
1277 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
|
1278 | - data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
|
1279 | - data-element_require='<?php if ( $element_require ) { |
|
1280 | - echo $this->convert_element_require( $element_require ); |
|
1277 | + <p class="sd-argument <?php echo esc_attr($class); ?>" |
|
1278 | + data-argument='<?php echo esc_attr($args['name']); ?>' |
|
1279 | + data-element_require='<?php if ($element_require) { |
|
1280 | + echo $this->convert_element_require($element_require); |
|
1281 | 1281 | } ?>' |
1282 | 1282 | > |
1283 | 1283 | <?php |
1284 | 1284 | |
1285 | 1285 | |
1286 | - switch ( $args['type'] ) { |
|
1286 | + switch ($args['type']) { |
|
1287 | 1287 | //array('text','password','number','email','tel','url','color') |
1288 | 1288 | case "text": |
1289 | 1289 | case "password": |
@@ -1294,46 +1294,46 @@ discard block |
||
1294 | 1294 | case "color": |
1295 | 1295 | ?> |
1296 | 1296 | <label |
1297 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
1297 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
1298 | 1298 | <input <?php echo $placeholder; ?> class="widefat" |
1299 | 1299 | <?php echo $custom_attributes; ?> |
1300 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
1301 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
1302 | - type="<?php echo esc_attr( $args['type'] ); ?>" |
|
1303 | - value="<?php echo esc_attr( $value ); ?>"> |
|
1300 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
1301 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
1302 | + type="<?php echo esc_attr($args['type']); ?>" |
|
1303 | + value="<?php echo esc_attr($value); ?>"> |
|
1304 | 1304 | <?php |
1305 | 1305 | |
1306 | 1306 | break; |
1307 | 1307 | case "select": |
1308 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
1309 | - if ( $multiple ) { |
|
1310 | - if ( empty( $value ) ) { |
|
1308 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
1309 | + if ($multiple) { |
|
1310 | + if (empty($value)) { |
|
1311 | 1311 | $value = array(); |
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | ?> |
1315 | 1315 | <label |
1316 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
1316 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
1317 | 1317 | <select <?php echo $placeholder; ?> class="widefat" |
1318 | 1318 | <?php echo $custom_attributes; ?> |
1319 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
1320 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
|
1321 | - if ( $multiple ) { |
|
1319 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
1320 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); |
|
1321 | + if ($multiple) { |
|
1322 | 1322 | echo "[]"; |
1323 | 1323 | } ?>" |
1324 | - <?php if ( $multiple ) { |
|
1324 | + <?php if ($multiple) { |
|
1325 | 1325 | echo "multiple"; |
1326 | 1326 | } //@todo not implemented yet due to gutenberg not supporting it |
1327 | 1327 | ?> |
1328 | 1328 | > |
1329 | 1329 | <?php |
1330 | 1330 | |
1331 | - if ( ! empty( $args['options'] ) ) { |
|
1332 | - foreach ( $args['options'] as $val => $label ) { |
|
1333 | - if ( $multiple ) { |
|
1334 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
1331 | + if (!empty($args['options'])) { |
|
1332 | + foreach ($args['options'] as $val => $label) { |
|
1333 | + if ($multiple) { |
|
1334 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
1335 | 1335 | } else { |
1336 | - $selected = selected( $value, $val, false ); |
|
1336 | + $selected = selected($value, $val, false); |
|
1337 | 1337 | } |
1338 | 1338 | echo "<option value='$val' " . $selected . ">$label</option>"; |
1339 | 1339 | } |
@@ -1345,32 +1345,32 @@ discard block |
||
1345 | 1345 | case "checkbox": |
1346 | 1346 | ?> |
1347 | 1347 | <input <?php echo $placeholder; ?> |
1348 | - <?php checked( 1, $value, true ) ?> |
|
1348 | + <?php checked(1, $value, true) ?> |
|
1349 | 1349 | <?php echo $custom_attributes; ?> |
1350 | - class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
1351 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" |
|
1350 | + class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
1351 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" |
|
1352 | 1352 | value="1"> |
1353 | 1353 | <label |
1354 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
1354 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
1355 | 1355 | <?php |
1356 | 1356 | break; |
1357 | 1357 | case "textarea": |
1358 | 1358 | ?> |
1359 | 1359 | <label |
1360 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
1360 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
1361 | 1361 | <textarea <?php echo $placeholder; ?> class="widefat" |
1362 | 1362 | <?php echo $custom_attributes; ?> |
1363 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
1364 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
1365 | - ><?php echo esc_attr( $value ); ?></textarea> |
|
1363 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
1364 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
1365 | + ><?php echo esc_attr($value); ?></textarea> |
|
1366 | 1366 | <?php |
1367 | 1367 | |
1368 | 1368 | break; |
1369 | 1369 | case "hidden": |
1370 | 1370 | ?> |
1371 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
1372 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
|
1373 | - value="<?php echo esc_attr( $value ); ?>"> |
|
1371 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
1372 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" |
|
1373 | + value="<?php echo esc_attr($value); ?>"> |
|
1374 | 1374 | <?php |
1375 | 1375 | break; |
1376 | 1376 | default: |
@@ -1392,25 +1392,25 @@ discard block |
||
1392 | 1392 | * |
1393 | 1393 | * @return string |
1394 | 1394 | */ |
1395 | - public function array_to_attributes( $attributes, $html = false ) { |
|
1395 | + public function array_to_attributes($attributes, $html = false) { |
|
1396 | 1396 | |
1397 | - if ( ! is_array( $attributes ) ) { |
|
1397 | + if (!is_array($attributes)) { |
|
1398 | 1398 | return ''; |
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | $output = ''; |
1402 | - foreach ( $attributes as $name => $value ) { |
|
1402 | + foreach ($attributes as $name => $value) { |
|
1403 | 1403 | |
1404 | - if ( $html ) { |
|
1404 | + if ($html) { |
|
1405 | 1405 | |
1406 | - if ( true === $value ) { |
|
1407 | - $output .= esc_html( $name ) . ' '; |
|
1408 | - } else if ( false !== $value ) { |
|
1409 | - $output .= sprintf( '%s="%s" ', esc_html( $name ), trim( esc_attr( $value ) ) ); |
|
1406 | + if (true === $value) { |
|
1407 | + $output .= esc_html($name) . ' '; |
|
1408 | + } else if (false !== $value) { |
|
1409 | + $output .= sprintf('%s="%s" ', esc_html($name), trim(esc_attr($value))); |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | } else { |
1413 | - $output .= sprintf( "'%s': '%s',", esc_js( $name ), is_bool( $value ) ? $value : trim( esc_js( $value ) ) ); |
|
1413 | + $output .= sprintf("'%s': '%s',", esc_js($name), is_bool($value) ? $value : trim(esc_js($value))); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | } |
@@ -1431,10 +1431,10 @@ discard block |
||
1431 | 1431 | * |
1432 | 1432 | * @return string ID attribute for `$field_name`. |
1433 | 1433 | */ |
1434 | - public function get_field_id( $field_name ) { |
|
1434 | + public function get_field_id($field_name) { |
|
1435 | 1435 | |
1436 | - $field_name = str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ); |
|
1437 | - $field_name = trim( $field_name, '-' ); |
|
1436 | + $field_name = str_replace(array('[]', '[', ']'), array('', '-', ''), $field_name); |
|
1437 | + $field_name = trim($field_name, '-'); |
|
1438 | 1438 | |
1439 | 1439 | return 'widget-' . $this->base_id . '-' . $this->get_number() . '-' . $field_name; |
1440 | 1440 | } |
@@ -1447,13 +1447,13 @@ discard block |
||
1447 | 1447 | public function get_number() { |
1448 | 1448 | static $number = 1; |
1449 | 1449 | |
1450 | - if ( isset( $this->output_types['widget'] ) ) { |
|
1450 | + if (isset($this->output_types['widget'])) { |
|
1451 | 1451 | return $this->output_types['widget']->number; |
1452 | 1452 | } |
1453 | 1453 | |
1454 | - if ( empty( $this->number ) ) { |
|
1454 | + if (empty($this->number)) { |
|
1455 | 1455 | $this->number = $number; |
1456 | - $number ++; |
|
1456 | + $number++; |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | return $this->number; |
@@ -1466,12 +1466,12 @@ discard block |
||
1466 | 1466 | * |
1467 | 1467 | * @return string |
1468 | 1468 | */ |
1469 | - public function widget_field_title( $args ) { |
|
1469 | + public function widget_field_title($args) { |
|
1470 | 1470 | |
1471 | 1471 | $title = ''; |
1472 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
1473 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
1474 | - $title = $this->get_widget_icon( $args['icon'], $args['title'] ); |
|
1472 | + if (isset($args['title']) && $args['title']) { |
|
1473 | + if (isset($args['icon']) && $args['icon']) { |
|
1474 | + $title = $this->get_widget_icon($args['icon'], $args['title']); |
|
1475 | 1475 | } else { |
1476 | 1476 | $title = esc_attr($args['title']); |
1477 | 1477 | } |
@@ -1485,15 +1485,15 @@ discard block |
||
1485 | 1485 | * |
1486 | 1486 | * @return array |
1487 | 1487 | */ |
1488 | - public function get_widget_icon( $icon = 'box-top', $title = '' ) { |
|
1489 | - if($icon=='box-top'){ |
|
1490 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
1491 | - }elseif($icon=='box-right'){ |
|
1492 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
1493 | - }elseif($icon=='box-bottom'){ |
|
1494 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
1495 | - }elseif($icon=='box-left'){ |
|
1496 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
1488 | + public function get_widget_icon($icon = 'box-top', $title = '') { |
|
1489 | + if ($icon == 'box-top') { |
|
1490 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
1491 | + }elseif ($icon == 'box-right') { |
|
1492 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
1493 | + }elseif ($icon == 'box-bottom') { |
|
1494 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
1495 | + }elseif ($icon == 'box-left') { |
|
1496 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
1497 | 1497 | } |
1498 | 1498 | } |
1499 | 1499 | |
@@ -1510,12 +1510,12 @@ discard block |
||
1510 | 1510 | * |
1511 | 1511 | * @return string Name attribute for `$field_name`. |
1512 | 1512 | */ |
1513 | - public function get_field_name( $field_name ) { |
|
1514 | - $pos = strpos( $field_name, '[' ); |
|
1513 | + public function get_field_name($field_name) { |
|
1514 | + $pos = strpos($field_name, '['); |
|
1515 | 1515 | |
1516 | - if ( false !== $pos ) { |
|
1516 | + if (false !== $pos) { |
|
1517 | 1517 | // Replace the first occurrence of '[' with ']['. |
1518 | - $field_name = '[' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); |
|
1518 | + $field_name = '[' . substr_replace($field_name, '][', $pos, strlen('[')); |
|
1519 | 1519 | } else { |
1520 | 1520 | $field_name = '[' . $field_name . ']'; |
1521 | 1521 | } |
@@ -1523,10 +1523,10 @@ discard block |
||
1523 | 1523 | return 'widget-' . $this->base_id . '[' . $this->get_number() . ']' . $field_name; |
1524 | 1524 | } |
1525 | 1525 | |
1526 | - public function widget_inputs_row_end($key, $args){ |
|
1527 | - if(!empty($args['row'])){ |
|
1526 | + public function widget_inputs_row_end($key, $args) { |
|
1527 | + if (!empty($args['row'])) { |
|
1528 | 1528 | // maybe close |
1529 | - if(!empty($args['row']['close'])){ |
|
1529 | + if (!empty($args['row']['close'])) { |
|
1530 | 1530 | echo "</div></div>"; |
1531 | 1531 | } |
1532 | 1532 | |
@@ -1542,14 +1542,14 @@ discard block |
||
1542 | 1542 | * @since 1.0.20 |
1543 | 1543 | * @return string |
1544 | 1544 | */ |
1545 | - public function get_instance_style($rules = array()){ |
|
1545 | + public function get_instance_style($rules = array()) { |
|
1546 | 1546 | $css = ''; |
1547 | 1547 | |
1548 | - if(!empty($rules)){ |
|
1548 | + if (!empty($rules)) { |
|
1549 | 1549 | $rules = array_unique($rules); |
1550 | 1550 | $instance_hash = $this->get_instance_hash(); |
1551 | 1551 | $css .= "<style>"; |
1552 | - foreach($rules as $rule){ |
|
1552 | + foreach ($rules as $rule) { |
|
1553 | 1553 | $css .= ".sdel-$instance_hash $rule"; |
1554 | 1554 | } |
1555 | 1555 | $css .= "</style>"; |
@@ -1564,9 +1564,9 @@ discard block |
||
1564 | 1564 | * @since 1.0.20 |
1565 | 1565 | * @return string |
1566 | 1566 | */ |
1567 | - public function get_instance_hash(){ |
|
1568 | - $instance_string = $this->base_id . serialize( $this->instance ); |
|
1569 | - return hash( 'crc32b', $instance_string ); |
|
1567 | + public function get_instance_hash() { |
|
1568 | + $instance_string = $this->base_id . serialize($this->instance); |
|
1569 | + return hash('crc32b', $instance_string); |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | /** |
@@ -2075,12 +2075,12 @@ discard block |
||
2075 | 2075 | } |
2076 | 2076 | }); |
2077 | 2077 | } |
2078 | - <?php do_action( 'wp_super_duper_conditional_fields_js', $this ); ?> |
|
2078 | + <?php do_action('wp_super_duper_conditional_fields_js', $this); ?> |
|
2079 | 2079 | </script> |
2080 | 2080 | <?php |
2081 | 2081 | $output = ob_get_clean(); |
2082 | 2082 | |
2083 | - return str_replace( array( '<script>', '</script>' ), '', trim( $output ) ); |
|
2083 | + return str_replace(array('<script>', '</script>'), '', trim($output)); |
|
2084 | 2084 | } |
2085 | 2085 | |
2086 | 2086 | /** |
@@ -2091,36 +2091,36 @@ discard block |
||
2091 | 2091 | * |
2092 | 2092 | * @return string |
2093 | 2093 | */ |
2094 | - public function output_title( $args, $instance = array() ) { |
|
2094 | + public function output_title($args, $instance = array()) { |
|
2095 | 2095 | $output = ''; |
2096 | 2096 | |
2097 | - if ( ! empty( $instance['title'] ) ) { |
|
2097 | + if (!empty($instance['title'])) { |
|
2098 | 2098 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
2099 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->base_id ); |
|
2099 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->base_id); |
|
2100 | 2100 | |
2101 | - if ( empty( $instance['widget_title_tag'] ) ) { |
|
2101 | + if (empty($instance['widget_title_tag'])) { |
|
2102 | 2102 | $output = $args['before_title'] . $title . $args['after_title']; |
2103 | 2103 | } else { |
2104 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
2104 | + $title_tag = esc_attr($instance['widget_title_tag']); |
|
2105 | 2105 | |
2106 | 2106 | // classes |
2107 | 2107 | $title_classes = array(); |
2108 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
2109 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
2110 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
2111 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
2112 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
2113 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
2114 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
2115 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
2116 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
2117 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
2118 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
2119 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
2120 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
2121 | - $title_classes = array_filter( $title_classes ); |
|
2122 | - |
|
2123 | - $class = ! empty( $title_classes ) ? implode( ' ', $title_classes ) : ''; |
|
2108 | + $title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : ''; |
|
2109 | + $title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : ''; |
|
2110 | + $title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : ''; |
|
2111 | + $title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : ''; |
|
2112 | + $title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : ''; |
|
2113 | + $title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : ''; |
|
2114 | + $title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : ''; |
|
2115 | + $title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : ''; |
|
2116 | + $title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : ''; |
|
2117 | + $title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : ''; |
|
2118 | + $title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : ''; |
|
2119 | + $title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : ''; |
|
2120 | + $title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : ''; |
|
2121 | + $title_classes = array_filter($title_classes); |
|
2122 | + |
|
2123 | + $class = !empty($title_classes) ? implode(' ', $title_classes) : ''; |
|
2124 | 2124 | $output = "<$title_tag class='$class' >$title</$title_tag>"; |
2125 | 2125 | } |
2126 | 2126 | |
@@ -2137,8 +2137,8 @@ discard block |
||
2137 | 2137 | * |
2138 | 2138 | * @return string|void |
2139 | 2139 | */ |
2140 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
2141 | - return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_insert_button( $editor_id, $insert_shortcode_function ) : ''; |
|
2140 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
2141 | + return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_insert_button($editor_id, $insert_shortcode_function) : ''; |
|
2142 | 2142 | } |
2143 | 2143 | |
2144 | 2144 | /** |
@@ -2149,8 +2149,8 @@ discard block |
||
2149 | 2149 | * |
2150 | 2150 | * @return mixed|string |
2151 | 2151 | */ |
2152 | - public static function shortcode_button( $id = '', $search_for_id = '') { |
|
2153 | - return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_button( $id, $search_for_id ) : ''; |
|
2152 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
2153 | + return class_exists('WP_Super_Duper_Shortcode') ? WP_Super_Duper_Shortcode::shortcode_button($id, $search_for_id) : ''; |
|
2154 | 2154 | } |
2155 | 2155 | |
2156 | 2156 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'root' => |
|
3 | - array ( |
|
2 | + 'root' => |
|
3 | + array ( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
@@ -8,94 +8,94 @@ discard block |
||
8 | 8 | ), |
9 | 9 | 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | - ), |
|
12 | - 'versions' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'versions' => |
|
13 | + array ( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | 15 | array ( |
16 | - 'pretty_version' => '1.0.3', |
|
17 | - 'version' => '1.0.3.0', |
|
18 | - 'aliases' => |
|
19 | - array ( |
|
20 | - ), |
|
21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
16 | + 'pretty_version' => '1.0.3', |
|
17 | + 'version' => '1.0.3.0', |
|
18 | + 'aliases' => |
|
19 | + array ( |
|
20 | + ), |
|
21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | 24 | array ( |
25 | - 'pretty_version' => 'dev-master', |
|
26 | - 'version' => 'dev-master', |
|
27 | - 'aliases' => |
|
28 | - array ( |
|
29 | - ), |
|
30 | - 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
|
25 | + 'pretty_version' => 'dev-master', |
|
26 | + 'version' => 'dev-master', |
|
27 | + 'aliases' => |
|
28 | + array ( |
|
29 | + ), |
|
30 | + 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
|
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | 33 | array ( |
34 | - 'pretty_version' => '0.1.61', |
|
35 | - 'version' => '0.1.61.0', |
|
36 | - 'aliases' => |
|
37 | - array ( |
|
38 | - ), |
|
39 | - 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
34 | + 'pretty_version' => '0.1.61', |
|
35 | + 'version' => '0.1.61.0', |
|
36 | + 'aliases' => |
|
37 | + array ( |
|
38 | + ), |
|
39 | + 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
40 | 40 | ), |
41 | 41 | 'ayecode/wp-deactivation-survey' => |
42 | 42 | array ( |
43 | - 'pretty_version' => '1.0.3', |
|
44 | - 'version' => '1.0.3.0', |
|
45 | - 'aliases' => |
|
46 | - array ( |
|
47 | - ), |
|
48 | - 'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667', |
|
43 | + 'pretty_version' => '1.0.3', |
|
44 | + 'version' => '1.0.3.0', |
|
45 | + 'aliases' => |
|
46 | + array ( |
|
47 | + ), |
|
48 | + 'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667', |
|
49 | 49 | ), |
50 | 50 | 'ayecode/wp-font-awesome-settings' => |
51 | 51 | array ( |
52 | - 'pretty_version' => '1.0.13', |
|
53 | - 'version' => '1.0.13.0', |
|
54 | - 'aliases' => |
|
55 | - array ( |
|
56 | - ), |
|
57 | - 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
52 | + 'pretty_version' => '1.0.13', |
|
53 | + 'version' => '1.0.13.0', |
|
54 | + 'aliases' => |
|
55 | + array ( |
|
56 | + ), |
|
57 | + 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
58 | 58 | ), |
59 | 59 | 'ayecode/wp-super-duper' => |
60 | 60 | array ( |
61 | - 'pretty_version' => '2.0.1', |
|
62 | - 'version' => '2.0.1.0', |
|
63 | - 'aliases' => |
|
64 | - array ( |
|
65 | - ), |
|
66 | - 'reference' => '7844e43f00d2e8f32c5883e46bdc5154da5a5487', |
|
61 | + 'pretty_version' => '2.0.1', |
|
62 | + 'version' => '2.0.1.0', |
|
63 | + 'aliases' => |
|
64 | + array ( |
|
65 | + ), |
|
66 | + 'reference' => '7844e43f00d2e8f32c5883e46bdc5154da5a5487', |
|
67 | 67 | ), |
68 | 68 | 'composer/installers' => |
69 | 69 | array ( |
70 | - 'pretty_version' => 'v1.12.0', |
|
71 | - 'version' => '1.12.0.0', |
|
72 | - 'aliases' => |
|
73 | - array ( |
|
74 | - ), |
|
75 | - 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
70 | + 'pretty_version' => 'v1.12.0', |
|
71 | + 'version' => '1.12.0.0', |
|
72 | + 'aliases' => |
|
73 | + array ( |
|
74 | + ), |
|
75 | + 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
76 | 76 | ), |
77 | 77 | 'maxmind-db/reader' => |
78 | 78 | array ( |
79 | - 'pretty_version' => 'v1.6.0', |
|
80 | - 'version' => '1.6.0.0', |
|
81 | - 'aliases' => |
|
82 | - array ( |
|
83 | - ), |
|
84 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
79 | + 'pretty_version' => 'v1.6.0', |
|
80 | + 'version' => '1.6.0.0', |
|
81 | + 'aliases' => |
|
82 | + array ( |
|
83 | + ), |
|
84 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
85 | 85 | ), |
86 | 86 | 'roundcube/plugin-installer' => |
87 | 87 | array ( |
88 | - 'replaced' => |
|
89 | - array ( |
|
88 | + 'replaced' => |
|
89 | + array ( |
|
90 | 90 | 0 => '*', |
91 | - ), |
|
91 | + ), |
|
92 | 92 | ), |
93 | 93 | 'shama/baton' => |
94 | 94 | array ( |
95 | - 'replaced' => |
|
96 | - array ( |
|
95 | + 'replaced' => |
|
96 | + array ( |
|
97 | 97 | 0 => '*', |
98 | - ), |
|
98 | + ), |
|
99 | + ), |
|
99 | 100 | ), |
100 | - ), |
|
101 | 101 | ); |
@@ -1,99 +1,99 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.61', |
35 | 35 | 'version' => '0.1.61.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-deactivation-survey' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.3', |
44 | 44 | 'version' => '1.0.3.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-font-awesome-settings' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.13', |
53 | 53 | 'version' => '1.0.13.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
58 | 58 | ), |
59 | 59 | 'ayecode/wp-super-duper' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => '2.0.1', |
62 | 62 | 'version' => '2.0.1.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => '7844e43f00d2e8f32c5883e46bdc5154da5a5487', |
67 | 67 | ), |
68 | 68 | 'composer/installers' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.12.0', |
71 | 71 | 'version' => '1.12.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
76 | 76 | ), |
77 | 77 | 'maxmind-db/reader' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'pretty_version' => 'v1.6.0', |
80 | 80 | 'version' => '1.6.0.0', |
81 | 81 | 'aliases' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | ), |
84 | 84 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
85 | 85 | ), |
86 | 86 | 'roundcube/plugin-installer' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 'replaced' => |
89 | - array ( |
|
89 | + array( |
|
90 | 90 | 0 => '*', |
91 | 91 | ), |
92 | 92 | ), |
93 | 93 | 'shama/baton' => |
94 | - array ( |
|
94 | + array( |
|
95 | 95 | 'replaced' => |
96 | - array ( |
|
96 | + array( |
|
97 | 97 | 0 => '*', |
98 | 98 | ), |
99 | 99 | ), |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | 14 | private static $installed = array ( |
15 | - 'root' => |
|
16 | - array ( |
|
15 | + 'root' => |
|
16 | + array ( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
@@ -21,96 +21,96 @@ discard block |
||
21 | 21 | ), |
22 | 22 | 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | - ), |
|
25 | - 'versions' => |
|
26 | - array ( |
|
24 | + ), |
|
25 | + 'versions' => |
|
26 | + array ( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | 28 | array ( |
29 | - 'pretty_version' => '1.0.3', |
|
30 | - 'version' => '1.0.3.0', |
|
31 | - 'aliases' => |
|
32 | - array ( |
|
33 | - ), |
|
34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
29 | + 'pretty_version' => '1.0.3', |
|
30 | + 'version' => '1.0.3.0', |
|
31 | + 'aliases' => |
|
32 | + array ( |
|
33 | + ), |
|
34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | 37 | array ( |
38 | - 'pretty_version' => 'dev-master', |
|
39 | - 'version' => 'dev-master', |
|
40 | - 'aliases' => |
|
41 | - array ( |
|
42 | - ), |
|
43 | - 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
|
38 | + 'pretty_version' => 'dev-master', |
|
39 | + 'version' => 'dev-master', |
|
40 | + 'aliases' => |
|
41 | + array ( |
|
42 | + ), |
|
43 | + 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
|
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | 46 | array ( |
47 | - 'pretty_version' => '0.1.61', |
|
48 | - 'version' => '0.1.61.0', |
|
49 | - 'aliases' => |
|
50 | - array ( |
|
51 | - ), |
|
52 | - 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
47 | + 'pretty_version' => '0.1.61', |
|
48 | + 'version' => '0.1.61.0', |
|
49 | + 'aliases' => |
|
50 | + array ( |
|
51 | + ), |
|
52 | + 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
53 | 53 | ), |
54 | 54 | 'ayecode/wp-deactivation-survey' => |
55 | 55 | array ( |
56 | - 'pretty_version' => '1.0.3', |
|
57 | - 'version' => '1.0.3.0', |
|
58 | - 'aliases' => |
|
59 | - array ( |
|
60 | - ), |
|
61 | - 'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667', |
|
56 | + 'pretty_version' => '1.0.3', |
|
57 | + 'version' => '1.0.3.0', |
|
58 | + 'aliases' => |
|
59 | + array ( |
|
60 | + ), |
|
61 | + 'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667', |
|
62 | 62 | ), |
63 | 63 | 'ayecode/wp-font-awesome-settings' => |
64 | 64 | array ( |
65 | - 'pretty_version' => '1.0.13', |
|
66 | - 'version' => '1.0.13.0', |
|
67 | - 'aliases' => |
|
68 | - array ( |
|
69 | - ), |
|
70 | - 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
65 | + 'pretty_version' => '1.0.13', |
|
66 | + 'version' => '1.0.13.0', |
|
67 | + 'aliases' => |
|
68 | + array ( |
|
69 | + ), |
|
70 | + 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
71 | 71 | ), |
72 | 72 | 'ayecode/wp-super-duper' => |
73 | 73 | array ( |
74 | - 'pretty_version' => '2.0.1', |
|
75 | - 'version' => '2.0.1.0', |
|
76 | - 'aliases' => |
|
77 | - array ( |
|
78 | - ), |
|
79 | - 'reference' => '7844e43f00d2e8f32c5883e46bdc5154da5a5487', |
|
74 | + 'pretty_version' => '2.0.1', |
|
75 | + 'version' => '2.0.1.0', |
|
76 | + 'aliases' => |
|
77 | + array ( |
|
78 | + ), |
|
79 | + 'reference' => '7844e43f00d2e8f32c5883e46bdc5154da5a5487', |
|
80 | 80 | ), |
81 | 81 | 'composer/installers' => |
82 | 82 | array ( |
83 | - 'pretty_version' => 'v1.12.0', |
|
84 | - 'version' => '1.12.0.0', |
|
85 | - 'aliases' => |
|
86 | - array ( |
|
87 | - ), |
|
88 | - 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
83 | + 'pretty_version' => 'v1.12.0', |
|
84 | + 'version' => '1.12.0.0', |
|
85 | + 'aliases' => |
|
86 | + array ( |
|
87 | + ), |
|
88 | + 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
89 | 89 | ), |
90 | 90 | 'maxmind-db/reader' => |
91 | 91 | array ( |
92 | - 'pretty_version' => 'v1.6.0', |
|
93 | - 'version' => '1.6.0.0', |
|
94 | - 'aliases' => |
|
95 | - array ( |
|
96 | - ), |
|
97 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
92 | + 'pretty_version' => 'v1.6.0', |
|
93 | + 'version' => '1.6.0.0', |
|
94 | + 'aliases' => |
|
95 | + array ( |
|
96 | + ), |
|
97 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
98 | 98 | ), |
99 | 99 | 'roundcube/plugin-installer' => |
100 | 100 | array ( |
101 | - 'replaced' => |
|
102 | - array ( |
|
101 | + 'replaced' => |
|
102 | + array ( |
|
103 | 103 | 0 => '*', |
104 | - ), |
|
104 | + ), |
|
105 | 105 | ), |
106 | 106 | 'shama/baton' => |
107 | 107 | array ( |
108 | - 'replaced' => |
|
109 | - array ( |
|
108 | + 'replaced' => |
|
109 | + array ( |
|
110 | 110 | 0 => '*', |
111 | - ), |
|
111 | + ), |
|
112 | + ), |
|
112 | 113 | ), |
113 | - ), |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 |
@@ -11,102 +11,102 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => 'e9e8ae2fe4e6391f1dea016f5f84493ae729008e', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.61', |
48 | 48 | 'version' => '0.1.61.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-deactivation-survey' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.3', |
57 | 57 | 'version' => '1.0.3.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-font-awesome-settings' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.13', |
66 | 66 | 'version' => '1.0.13.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
71 | 71 | ), |
72 | 72 | 'ayecode/wp-super-duper' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => '2.0.1', |
75 | 75 | 'version' => '2.0.1.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => '7844e43f00d2e8f32c5883e46bdc5154da5a5487', |
80 | 80 | ), |
81 | 81 | 'composer/installers' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.12.0', |
84 | 84 | 'version' => '1.12.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
89 | 89 | ), |
90 | 90 | 'maxmind-db/reader' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'pretty_version' => 'v1.6.0', |
93 | 93 | 'version' => '1.6.0.0', |
94 | 94 | 'aliases' => |
95 | - array ( |
|
95 | + array( |
|
96 | 96 | ), |
97 | 97 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
98 | 98 | ), |
99 | 99 | 'roundcube/plugin-installer' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 'replaced' => |
102 | - array ( |
|
102 | + array( |
|
103 | 103 | 0 => '*', |
104 | 104 | ), |
105 | 105 | ), |
106 | 106 | 'shama/baton' => |
107 | - array ( |
|
107 | + array( |
|
108 | 108 | 'replaced' => |
109 | - array ( |
|
109 | + array( |
|
110 | 110 | 0 => '*', |
111 | 111 | ), |
112 | 112 | ), |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | |
20 | 20 | // Define constants. |
21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
26 | - define( 'WPINV_VERSION', '2.5.0' ); |
|
26 | + define( 'WPINV_VERSION', '2.5.0' ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
46 | - return $GLOBALS['invoicing']; |
|
46 | + return $GLOBALS['invoicing']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @package GetPaid |
16 | 16 | */ |
17 | 17 | |
18 | -defined( 'ABSPATH' ) || exit; |
|
18 | +defined('ABSPATH') || exit; |
|
19 | 19 | |
20 | 20 | // Define constants. |
21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
26 | - define( 'WPINV_VERSION', '2.5.0' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '2.5.0'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function getpaid() { |
41 | 41 | |
42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
42 | + if (empty($GLOBALS['invoicing'])) { |
|
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 2.0.8 |
53 | 53 | */ |
54 | 54 | function getpaid_deactivation_hook() { |
55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
55 | + update_option('wpinv_flush_permalinks', 1); |
|
56 | 56 | } |
57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Kickstart the plugin. |
67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
67 | +add_action('plugins_loaded', 'getpaid', -100); |