PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 2.0.14
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v2.0.14
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.0.14, at admin/customizer/controls.php

488 lines 17.0 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 ?>
232 <label>
233 <h4 class="betterdocs-customize-control-separator"><?php echo esc_html( $this->label ); ?></h4>
234 <?php if ( ! empty( $this->description ) ) : ?>
235 <span class="description customize-control-description"><?php echo $this->description; ?></span>
236 <?php endif; ?>
237 </label>
238 <?php
239 }
240 }
241
242 /**
243 * Title Custom Customizer Control
244 *
245 * Class BetterDocs_Title_Custom_Control
246 *
247 * @since 1.0.0
248 */
249
250 class BetterDocs_Title_Custom_Control extends WP_Customize_Control{
251 public $type = 'betterdocs-title';
252 public function render_content() {
253 ?>
254 <div <?php echo $this->input_attrs(); ?>>
255 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
256 <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>
257 <?php if ( ! empty( $this->description ) ) : ?>
258 <span class="description customize-control-description"><?php echo $this->description; ?></span>
259 <?php endif; ?>
260 </div>
261 <?php
262 }
263 }
264
265
266 /**
267 * Select Customizer Control
268 *
269 * Class BetterDocs_Select_Control
270 *
271 * @since 1.0.0
272 */
273
274 class BetterDocs_Select_Control extends WP_Customize_Control {
275
276 public $type = 'betterdocs-select';
277 public function render_content() {
278 if( empty( $this->choices ) )
279 return;
280 ?>
281 <select <?php $this->link(); ?> data-default-val="<?php echo $this->settings[ 'default' ]->value(); ?>" <?php echo $this->input_attrs(); ?>>
282 <?php
283 foreach( $this->choices as $key => $label ) {
284 echo '<option value="' . esc_attr( $key ) . '">' . $label . '</option>';
285 }
286 ?>
287 </select>
288 <?php if( !empty( $this->label ) ) : ?>
289 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
290 <?php endif;
291 }
292
293 }
294
295 /**
296 * Dimension Customizer Control
297 *
298 * Class BetterDocs_Dimension_Control
299 *
300 * @since 1.0.0
301 */
302
303 class BetterDocs_Dimension_Control extends WP_Customize_Control {
304 public $type = 'betterdocs-dimension';
305
306 /**
307 * Render the control's content.
308 *
309 * @since 1.0.0
310 */
311 public function render_content() {
312 ?>
313 <div class="dimension-field">
314 <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(); ?>>
315 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
316 </div>
317 <?php
318 }
319 }
320
321 /**
322 * Number Customizer Control
323 *
324 * Class BetterDocs_Dimension_Control
325 *
326 * @since 1.0.0
327 */
328
329 class BetterDocs_Padding_Control extends WP_Customize_Control {
330 public $type = 'betterdocs-padding';
331
332 /**
333 * Render the control's content.
334 *
335 * @since 1.0.0
336 */
337 public function render_content() {
338 ?>
339 <div class="number-field">
340 <?php
341 $controller_id = esc_attr($this->id);
342 $val_top = get_theme_mod($this->id.'_top');
343 $val_left = get_theme_mod($this->id.'_left');
344 ?>
345 <?php if ( ! empty( $this->label ) ) : ?>
346 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
347 <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>
348 <?php endif; ?>
349 <!-- <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(); ?>> -->
350 <ul>
351 <li id="<?php echo $controller_id . '_top' ?>" class="customize-control">
352 <input type="number" data-default-val="20" class="<?php echo $this->type ?>" value="20" data-customize-setting-link="<?php echo $controller_id . '_top' ?>" >
353 </li>
354 <li id="<?php echo $controller_id . '_left' ?>" class="customize-control">
355 <input type="number" data-default-val="20" class="<?php echo $this->type ?>" value="20" data-customize-setting-link="<?php echo $controller_id . '_left' ?>">
356 </li>
357 </ul>
358 </div>
359 <?php
360 }
361 }
362
363
364 /**
365 * Number Customizer Control
366 *
367 * Class BetterDocs_Dimension_Control
368 *
369 * @since 1.0.0
370 */
371
372 class BetterDocs_Number_Control extends WP_Customize_Control {
373 public $type = 'betterdocs-number';
374
375 /**
376 * Render the control's content.
377 *
378 * @since 1.0.0
379 */
380 public function render_content() {
381 ?>
382 <div class="number-field">
383 <?php if ( ! empty( $this->label ) ) : ?>
384 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
385 <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>
386 <?php endif; ?>
387 <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(); ?>>
388 <?php if ( ! empty( $this->description ) ) : ?>
389 <span class="description customize-control-description"><?php echo $this->description; ?></span>
390 <?php endif; ?>
391 </div>
392 <?php
393 }
394 }
395
396 class BetterDocs_Radio_Image_Control extends WP_Customize_Control {
397 /**
398 * Declare the control type.
399 *
400 * @since 1.0.0
401 */
402 public $type = 'betterdocs-radio-image';
403
404 /**
405 * Enqueue scripts/styles.
406 *
407 * @since 1.0.0
408 */
409 public function enqueue() {
410 wp_enqueue_script( 'jquery-ui-button' );
411 wp_enqueue_style(
412 'betterdocs-customizer-radio-image-select',
413 BETTERDOCS_ADMIN_URL . 'assets/css/customizer-radio-image-select.css',
414 array(),
415 rand()
416 );
417 }
418
419 /**
420 * Render the control's content.
421 *
422 * @since 1.0.0
423 */
424 public function render_content() {
425 if ( empty( $this->choices ) ) {
426 return;
427 }
428
429 $name = '_customize-radio-' . $this->id;
430 ?>
431 <?php if ( ! empty( $this->label ) ) : ?>
432 <span class="customize-control-title betterdocs-customize-control-title"><?php echo esc_html( $this->label ); ?></span>
433 <?php endif; ?>
434 <?php if ( ! empty( $this->description ) ) : ?>
435 <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span>
436 <?php endif; ?>
437 <div id="input_<?php echo $this->id; ?>" class="image ui-buttonset">
438 <?php
439 foreach ( $this->choices as $value => $label ) :
440 if(isset( $label['pro'] ) && $label['pro'] === true){ ?>
441 <label class="image-select" id="<?php echo $this->id . $value ?>">
442 <a target="_blank" href="<?php echo esc_url($label['url']) ?>"><img src="<?php echo esc_url( $label['image'] ) ?>" alt=""></a>
443 <span class="go-pro"><?php esc_html_e('Go Pro','betterdocs') ?></span>
444 </label>
445 <?php } else { ?>
446 <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 ); ?>>
447 <label for="<?php echo $this->id . $value; ?>">
448 <img src="<?php echo esc_url( $label['image'] ) ?>" alt="<?php echo esc_attr( $value ) ?>" title="<?php echo esc_attr( $value ) ?>">
449 </label>
450 </input>
451 <?php } endforeach; ?>
452 </div>
453 <script>jQuery(document).ready(function($) { $( '[id="input_<?php echo $this->id; ?>"]' ).buttonset(); });</script>
454 <?php
455 }
456 }
457
458 /**
459 * Load customizer conditional controler js file.
460 *
461 * @since 1.0.0
462 */
463
464 function betterdocs_customizer_condition() {
465 wp_enqueue_script( 'betterdocs-customize-condition',
466 BETTERDOCS_ADMIN_URL . 'assets/js/customizer-condition.js',
467 array(),
468 true
469 );
470 }
471 add_action( 'customize_controls_enqueue_scripts', 'betterdocs_customizer_condition' );
472
473 /**
474 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
475 *
476 * @since 1.0.0
477 */
478 function betterdocs_customize_preview_js() {
479 wp_enqueue_script( 'betterdocs-customizer',
480 BETTERDOCS_ADMIN_URL . 'assets/js/customizer.js',
481 array( 'customize-preview' ),
482 '',
483 true
484 );
485 }
486 add_action( 'customize_preview_init', 'betterdocs_customize_preview_js' );
487 ?>
488