PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 2.2.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v2.2.2
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / admin / customizer / controls.php

controls.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 2.2.2, at admin/customizer/controls.php

489 lines 17.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // No direct access, please
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 /**
6 * Range Value Customizer Control
7 *
8 * Class BetterDocs_Customizer_Range_Value_Control
9 *
10 * @since 1.0.0
11 */
12 class BetterDocs_Customizer_Range_Value_Control extends WP_Customize_Control {
13 public $type = 'betterdocs-range-value';
14
15 /**
16 * Enqueue scripts/styles.
17 *
18 * @since 1.0.0
19 */
20 public function enqueue() {
21 wp_enqueue_script(
22 'betterdocs-customizer-range-value-control',
23 BETTERDOCS_ADMIN_URL . 'assets/js/customizer-range-value-control.js',
24 array( 'jquery' ),
25 rand(),
26 true
27 );
28
29 wp_enqueue_style(
30 'betterdocs-customizer-range-value-control', BETTERDOCS_ADMIN_URL . 'assets/css/customizer-range-value-control.css',
31 array(),
32 rand()
33 );
34 }
35
36 /**
37 * Render the control's content.
38 *
39 * @version 1.0.0
40 *
41 */
42 public function render_content() {
43 ?>
44 <?php if ( ! empty( $this->label ) ) : ?>
45 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
46 <a href="#" title="<?php echo esc_html__('Reset', 'betterdocs') ?>" class="betterdocs-customizer-reset <?php echo esc_html( $this->type ); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="20px"><path d="M 25 2 C 12.321124 2 2 12.321124 2 25 C 2 37.678876 12.321124 48 25 48 C 37.678876 48 48 37.678876 48 25 A 2.0002 2.0002 0 1 0 44 25 C 44 35.517124 35.517124 44 25 44 C 14.482876 44 6 35.517124 6 25 C 6 14.482876 14.482876 6 25 6 C 30.475799 6 35.391893 8.3080175 38.855469 12 L 35 12 A 2.0002 2.0002 0 1 0 35 16 L 46 16 L 46 5 A 2.0002 2.0002 0 0 0 43.970703 2.9726562 A 2.0002 2.0002 0 0 0 42 5 L 42 9.5253906 C 37.79052 4.9067015 31.727675 2 25 2 z"></path></svg></a>
47 <?php endif; ?>
48 <div class="betterdcos-range-slider" data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" style="width:100%; display:flex;flex-direction: row;justify-content: flex-start;">
49 <span style="width:100%; flex: 1 0 0; vertical-align: middle;"><input class="betterdcos-range-slider__range" type="range" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->input_attrs(); $this->link(); ?>>
50 <span class="betterdcos-range-slider__value">0</span></span>
51 </div>
52 <?php if ( ! empty( $this->description ) ) : ?>
53 <span class="description customize-control-description"><?php echo $this->description; ?></span>
54 <?php endif; ?>
55 <?php
56 }
57 }
58
59 /**
60 * Toogle Customizer Control
61 *
62 * Class BetterDocs_Customizer_Toggle_Control
63 *
64 * @since 1.0.0
65 *
66 */
67 class BetterDocs_Customizer_Toggle_Control extends WP_Customize_Control {
68 public $type = 'betterdocs-toggle';
69
70 /**
71 * Enqueue scripts/styles.
72 *
73 * @since 1.0.0
74 */
75 public function enqueue() {
76 wp_enqueue_script( 'betterdocs-customizer-toggle-control',
77 BETTERDOCS_ADMIN_URL . 'assets/js/customizer-toggle-control.js',
78 array( 'jquery' ),
79 rand(),
80 true
81 );
82 wp_enqueue_style( 'betterdocs-pure-css-toggle-buttons',
83 BETTERDOCS_ADMIN_URL . 'assets/css/customizer-togle-buttons.css',
84 array(),
85 rand()
86 );
87
88 $css = '
89 .disabled-control-title {
90 color: #a0a5aa;
91 }
92 input[type=checkbox].tgl-light:checked + .tgl-btn {
93 background: #37de89;
94 }
95 input[type=checkbox].tgl-light + .tgl-btn {
96 background: #a0a5aa;
97 }
98 input[type=checkbox].tgl-light + .tgl-btn:after {
99 background: #f7f7f7;
100 }
101
102 input[type=checkbox].tgl-ios:checked + .tgl-btn {
103 background: #37de89;
104 }
105
106 input[type=checkbox].tgl-flat:checked + .tgl-btn {
107 border: 4px solid #37de89;
108 }
109 input[type=checkbox].tgl-flat:checked + .tgl-btn:after {
110 background: #37de89;
111 }
112
113 ';
114 wp_add_inline_style( 'pure-css-toggle-buttons' , $css );
115 }
116
117 /**
118 * Render the control's content.
119 *
120 * @version 1.0.0
121 *
122 */
123 public function render_content() {
124 ?>
125 <label>
126 <div class="betterdocs-customizer-toggle">
127 <span class="customize-control-title betterdocs-customize-control-title betterdocs-customizer-toggle-title"><?php echo esc_html( $this->label ); ?></span>
128 <input id="cb<?php echo $this->instance_number ?>" type="checkbox" data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" class="tgl tgl-<?php echo $this->type?> <?php echo $this->type?>" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); checked( $this->value() ); ?> />
129 <label for="cb<?php echo $this->instance_number ?>" class="tgl-btn"></label>
130 </div>
131 <?php if ( ! empty( $this->description ) ) : ?>
132 <span class="description customize-control-description"><?php echo $this->description; ?></span>
133 <?php endif; ?>
134 </label>
135 <?php
136 }
137 }
138
139 /**
140 * Alpha Color Picker Customizer Control
141 *
142 * Class BetterDocs_Customizer_Alpha_Color_Control
143 *
144 * @since 1.0.0
145 */
146
147 class BetterDocs_Customizer_Alpha_Color_Control extends WP_Customize_Control {
148 /**
149 * Official control name.
150 *
151 * @var string
152 */
153 public $type = 'betterdocs-alpha-color';
154 /**
155 * Add support for palettes to be passed in.
156 *
157 * Supported palette values are true, false, or an array of RGBa and Hex colors.
158 *
159 * @var bool
160 */
161 public $palette;
162 /**
163 * Add support for showing the opacity value on the slider handle.
164 *
165 * @var array
166 */
167 public $show_opacity;
168 /**
169 * Enqueue scripts/styles.
170 *
171 * @since 1.0.0
172 *
173 */
174 public function enqueue() {
175 wp_enqueue_script(
176 'betterdocs-customizer-alpha-color-picker',
177 BETTERDOCS_ADMIN_URL . 'assets/js/alpha-color-picker.js',
178 array( 'jquery', 'wp-color-picker' ),
179 rand(),
180 true
181 );
182 wp_enqueue_style(
183 'betterdocs-customizer-alpha-color-picker',
184 BETTERDOCS_ADMIN_URL . 'assets/css/alpha-color-picker.css',
185 array( 'wp-color-picker' ),
186 rand()
187 );
188 }
189 /**
190 * Render the control.
191 */
192 public function render_content() {
193 echo '<div class="betterdocs-alpha-color-picker">';
194 // Output the label and description if they were passed in.
195 if ( isset( $this->label ) && '' !== $this->label ) {
196 echo '<span class="customize-control-title betterdocs-customize-control-title">' . sanitize_text_field( $this->label ) . '</span>';
197 }
198 if ( isset( $this->description ) && '' !== $this->description ) {
199 echo '<span class="description customize-control-description">' . sanitize_text_field( $this->description ) . '</span>';
200 }
201
202 // Process the palette
203 if ( is_array( $this->palette ) ) {
204 $palette = implode( '|', $this->palette );
205 } else {
206 // Default to true.
207 $palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true';
208 }
209 // Support passing show_opacity as string or boolean. Default to true.
210 $show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true';
211 // Begin the output.
212 ?>
213 <input class="betterdocs-alpha-color-control" type="text" data-show-opacity="<?php echo esc_attr( $show_opacity ); ?>" data-palette="<?php echo esc_attr( $palette ); ?>" data-default-color="<?php echo esc_attr( $this->settings['default']->default ); ?>" <?php esc_attr( $this->link() ); ?> />
214
215 <?php
216 echo '</div>';
217 }
218 }
219
220 /**
221 * Seperator Custom Customizer Control
222 *
223 * Class BetterDocs_Separator_Custom_Control
224 *
225 * @since 1.0.0
226 */
227
228 class BetterDocs_Separator_Custom_Control extends WP_Customize_Control{
229 public $type = 'separator';
230 public function render_content(){
231 $custom_class = isset( $this->input_attrs['class'] ) ? ' '.$this->input_attrs['class'] : '';
232 ?>
233 <label>
234 <h4 class="betterdocs-customize-control-separator<?php echo $custom_class; ?>"><?php echo esc_html( $this->label ); ?></h4>
235 <?php if ( ! empty( $this->description ) ) : ?>
236 <span class="description customize-control-description"><?php echo $this->description; ?></span>
237 <?php endif; ?>
238 </label>
239 <?php
240 }
241 }
242
243 /**
244 * Title Custom Customizer Control
245 *
246 * Class BetterDocs_Title_Custom_Control
247 *
248 * @since 1.0.0
249 */
250
251 class BetterDocs_Title_Custom_Control extends WP_Customize_Control{
252 public $type = 'betterdocs-title';
253 public function render_content() {
254 ?>
255 <div <?php echo $this->input_attrs(); ?>>
256 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
257 <a href="#" title="<?php echo esc_html__('Reset', 'betterdocs') ?>" class="betterdocs-customizer-reset"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="20px"><path d="M 25 2 C 12.321124 2 2 12.321124 2 25 C 2 37.678876 12.321124 48 25 48 C 37.678876 48 48 37.678876 48 25 A 2.0002 2.0002 0 1 0 44 25 C 44 35.517124 35.517124 44 25 44 C 14.482876 44 6 35.517124 6 25 C 6 14.482876 14.482876 6 25 6 C 30.475799 6 35.391893 8.3080175 38.855469 12 L 35 12 A 2.0002 2.0002 0 1 0 35 16 L 46 16 L 46 5 A 2.0002 2.0002 0 0 0 43.970703 2.9726562 A 2.0002 2.0002 0 0 0 42 5 L 42 9.5253906 C 37.79052 4.9067015 31.727675 2 25 2 z"></path></svg></a>
258 <?php if ( ! empty( $this->description ) ) : ?>
259 <span class="description customize-control-description"><?php echo $this->description; ?></span>
260 <?php endif; ?>
261 </div>
262 <?php
263 }
264 }
265
266
267 /**
268 * Select Customizer Control
269 *
270 * Class BetterDocs_Select_Control
271 *
272 * @since 1.0.0
273 */
274
275 class BetterDocs_Select_Control extends WP_Customize_Control {
276
277 public $type = 'betterdocs-select';
278 public function render_content() {
279 if( empty( $this->choices ) )
280 return;
281 ?>
282 <select <?php $this->link(); ?> data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" <?php echo $this->input_attrs(); ?>>
283 <?php
284 foreach( $this->choices as $key => $label ) {
285 echo '<option value="' . esc_attr( $key ) . '">' . $label . '</option>';
286 }
287 ?>
288 </select>
289 <?php if( !empty( $this->label ) ) : ?>
290 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
291 <?php endif;
292 }
293
294 }
295
296 /**
297 * Dimension Customizer Control
298 *
299 * Class BetterDocs_Dimension_Control
300 *
301 * @since 1.0.0
302 */
303
304 class BetterDocs_Dimension_Control extends WP_Customize_Control {
305 public $type = 'betterdocs-dimension';
306
307 /**
308 * Render the control's content.
309 *
310 * @since 1.0.0
311 */
312 public function render_content() {
313 ?>
314 <div class="dimension-field">
315 <input type="number" data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" value="<?php echo esc_attr($this->value()); ?>" <?php $this->input_attrs(); $this->link(); ?>>
316 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
317 </div>
318 <?php
319 }
320 }
321
322 /**
323 * Number Customizer Control
324 *
325 * Class BetterDocs_Dimension_Control
326 *
327 * @since 1.0.0
328 */
329
330 class BetterDocs_Padding_Control extends WP_Customize_Control {
331 public $type = 'betterdocs-padding';
332
333 /**
334 * Render the control's content.
335 *
336 * @since 1.0.0
337 */
338 public function render_content() {
339 ?>
340 <div class="number-field">
341 <?php
342 $controller_id = esc_attr($this->id);
343 $val_top = get_theme_mod($this->id.'_top');
344 $val_left = get_theme_mod($this->id.'_left');
345 ?>
346 <?php if ( ! empty( $this->label ) ) : ?>
347 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
348 <a href="#" title="<?php echo esc_html__('Reset', 'betterdocs') ?>" class="betterdocs-customizer-reset <?php echo esc_html( $this->type ); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="20px"><path d="M 25 2 C 12.321124 2 2 12.321124 2 25 C 2 37.678876 12.321124 48 25 48 C 37.678876 48 48 37.678876 48 25 A 2.0002 2.0002 0 1 0 44 25 C 44 35.517124 35.517124 44 25 44 C 14.482876 44 6 35.517124 6 25 C 6 14.482876 14.482876 6 25 6 C 30.475799 6 35.391893 8.3080175 38.855469 12 L 35 12 A 2.0002 2.0002 0 1 0 35 16 L 46 16 L 46 5 A 2.0002 2.0002 0 0 0 43.970703 2.9726562 A 2.0002 2.0002 0 0 0 42 5 L 42 9.5253906 C 37.79052 4.9067015 31.727675 2 25 2 z"></path></svg></a>
349 <?php endif; ?>
350 <!-- <input type="hidden" data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" class="<?php echo $this->type.' '.$this->id ?> ?>" value="<?php echo esc_attr($this->value()) ?>" <?php $this->input_attrs(); $this->link(); ?>> -->
351 <ul>
352 <li id="<?php echo $controller_id . '_top' ?>" class="customize-control">
353 <input type="number" data-default-val="20" class="<?php echo $this->type ?>" value="20" data-customize-setting-link="<?php echo $controller_id . '_top' ?>" >
354 </li>
355 <li id="<?php echo $controller_id . '_left' ?>" class="customize-control">
356 <input type="number" data-default-val="20" class="<?php echo $this->type ?>" value="20" data-customize-setting-link="<?php echo $controller_id . '_left' ?>">
357 </li>
358 </ul>
359 </div>
360 <?php
361 }
362 }
363
364
365 /**
366 * Number Customizer Control
367 *
368 * Class BetterDocs_Dimension_Control
369 *
370 * @since 1.0.0
371 */
372
373 class BetterDocs_Number_Control extends WP_Customize_Control {
374 public $type = 'betterdocs-number';
375
376 /**
377 * Render the control's content.
378 *
379 * @since 1.0.0
380 */
381 public function render_content() {
382 ?>
383 <div class="number-field">
384 <?php if ( ! empty( $this->label ) ) : ?>
385 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
386 <a href="#" title="<?php echo esc_html__('Reset', 'betterdocs') ?>" class="betterdocs-customizer-reset <?php echo esc_html( $this->type ); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="20px"><path d="M 25 2 C 12.321124 2 2 12.321124 2 25 C 2 37.678876 12.321124 48 25 48 C 37.678876 48 48 37.678876 48 25 A 2.0002 2.0002 0 1 0 44 25 C 44 35.517124 35.517124 44 25 44 C 14.482876 44 6 35.517124 6 25 C 6 14.482876 14.482876 6 25 6 C 30.475799 6 35.391893 8.3080175 38.855469 12 L 35 12 A 2.0002 2.0002 0 1 0 35 16 L 46 16 L 46 5 A 2.0002 2.0002 0 0 0 43.970703 2.9726562 A 2.0002 2.0002 0 0 0 42 5 L 42 9.5253906 C 37.79052 4.9067015 31.727675 2 25 2 z"></path></svg></a>
387 <?php endif; ?>
388 <input type="number" data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" class="<?php echo $this->type ?>" value="<?php echo esc_attr($this->value()); ?>" <?php $this->input_attrs(); $this->link(); ?>>
389 <?php if ( ! empty( $this->description ) ) : ?>
390 <span class="description customize-control-description"><?php echo $this->description; ?></span>
391 <?php endif; ?>
392 </div>
393 <?php
394 }
395 }
396
397 class BetterDocs_Radio_Image_Control extends WP_Customize_Control {
398 /**
399 * Declare the control type.
400 *
401 * @since 1.0.0
402 */
403 public $type = 'betterdocs-radio-image';
404
405 /**
406 * Enqueue scripts/styles.
407 *
408 * @since 1.0.0
409 */
410 public function enqueue() {
411 wp_enqueue_script( 'jquery-ui-button' );
412 wp_enqueue_style(
413 'betterdocs-customizer-radio-image-select',
414 BETTERDOCS_ADMIN_URL . 'assets/css/customizer-radio-image-select.css',
415 array(),
416 rand()
417 );
418 }
419
420 /**
421 * Render the control's content.
422 *
423 * @since 1.0.0
424 */
425 public function render_content() {
426 if ( empty( $this->choices ) ) {
427 return;
428 }
429
430 $name = '_customize-radio-' . $this->id;
431 ?>
432 <?php if ( ! empty( $this->label ) ) : ?>
433 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
434 <?php endif; ?>
435 <?php if ( ! empty( $this->description ) ) : ?>
436 <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span>
437 <?php endif; ?>
438 <div id="input_<?php echo $this->id; ?>" class="image ui-buttonset">
439 <?php
440 foreach ( $this->choices as $value => $label ) :
441 if(isset( $label['pro'] ) && $label['pro'] === true){ ?>
442 <label class="image-select" id="<?php echo $this->id . $value ?>">
443 <a target="_blank" href="<?php echo esc_url($label['url']) ?>"><img src="<?php echo esc_url( $label['image'] ) ?>" alt=""></a>
444 <span class="go-pro"><?php esc_html_e('Go Pro','betterdocs') ?></span>
445 </label>
446 <?php } else { ?>
447 <input class="image-select" type="radio" value="<?php echo esc_attr( $value ) ?>" id="<?php echo $this->id . $value; ?>" name="<?php echo esc_attr( $name ) ?>" <?php $this->link(); checked( $this->value(), $value ); ?>>
448 <label for="<?php echo $this->id . $value; ?>">
449 <img src="<?php echo esc_url( $label['image'] ) ?>" alt="<?php echo esc_attr( $value ) ?>" title="<?php echo isset( $label['label'] ) ? esc_attr( $label['label'] ) : '' ; ?>">
450 </label>
451 </input>
452 <?php } endforeach; ?>
453 </div>
454 <script>jQuery(document).ready(function($) { $( '[id="input_<?php echo $this->id; ?>"]' ).buttonset(); });</script>
455 <?php
456 }
457 }
458
459 /**
460 * Load customizer conditional controler js file.
461 *
462 * @since 1.0.0
463 */
464
465 function betterdocs_customizer_condition() {
466 wp_enqueue_script( 'betterdocs-customize-condition',
467 BETTERDOCS_ADMIN_URL . 'assets/js/customizer-condition.js',
468 array(),
469 true
470 );
471 }
472 add_action( 'customize_controls_enqueue_scripts', 'betterdocs_customizer_condition' );
473
474 /**
475 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
476 *
477 * @since 1.0.0
478 */
479 function betterdocs_customize_preview_js() {
480 wp_enqueue_script( 'betterdocs-customizer',
481 BETTERDOCS_ADMIN_URL . 'assets/js/customizer.js',
482 array( 'customize-preview' ),
483 '',
484 true
485 );
486 }
487 add_action( 'customize_preview_init', 'betterdocs_customize_preview_js' );
488 ?>
489