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

446 lines 14.3 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"><?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 = 'ios';
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 style="display:flex;flex-direction: row;justify-content: flex-start;">
127 <span class="customize-control-title" style="flex: 2 0 0; vertical-align: middle;"><?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 = '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">' . 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"><?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"><?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"><?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_Number_Control extends WP_Customize_Control {
330 public $type = 'betterdocs-number';
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 if ( ! empty( $this->label ) ) : ?>
341 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
342 <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>
343 <?php endif; ?>
344 <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(); ?>>
345 <?php if ( ! empty( $this->description ) ) : ?>
346 <span class="description customize-control-description"><?php echo $this->description; ?></span>
347 <?php endif; ?>
348 </div>
349 <?php
350 }
351 }
352
353 class BetterDocs_Radio_Image_Control extends WP_Customize_Control {
354 /**
355 * Declare the control type.
356 *
357 * @since 1.0.0
358 */
359 public $type = 'betterdocs-radio-image';
360
361 /**
362 * Enqueue scripts/styles.
363 *
364 * @since 1.0.0
365 */
366 public function enqueue() {
367 wp_enqueue_script( 'jquery-ui-button' );
368 wp_enqueue_style(
369 'betterdocs-customizer-radio-image-select',
370 BETTERDOCS_ADMIN_URL . 'assets/css/customizer-radio-image-select.css',
371 array(),
372 rand()
373 );
374 }
375
376 /**
377 * Render the control's content.
378 *
379 * @since 1.0.0
380 */
381 public function render_content() {
382 if ( empty( $this->choices ) ) {
383 return;
384 }
385
386 $name = '_customize-radio-' . $this->id;
387 ?>
388 <?php if ( ! empty( $this->label ) ) : ?>
389 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
390 <?php endif; ?>
391 <?php if ( ! empty( $this->description ) ) : ?>
392 <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span>
393 <?php endif; ?>
394 <div id="input_<?php echo $this->id; ?>" class="image ui-buttonset">
395 <?php
396 foreach ( $this->choices as $value => $label ) :
397 if(isset( $label['pro'] ) && $label['pro'] === true){ ?>
398 <label class="image-select" id="<?php echo $this->id . $value ?>">
399 <a target="_blank" href="<?php echo esc_url($label['url']) ?>"><img src="<?php echo esc_url( $label['image'] ) ?>" alt=""></a>
400 <span class="go-pro"><?php esc_html_e('Go Pro','betterdocs') ?></span>
401 </label>
402 <?php } else { ?>
403 <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 ); ?>>
404 <label for="<?php echo $this->id . $value; ?>">
405 <img src="<?php echo esc_url( $label['image'] ) ?>" alt="<?php echo esc_attr( $value ) ?>" title="<?php echo esc_attr( $value ) ?>">
406 </label>
407 </input>
408 <?php } endforeach; ?>
409 </div>
410 <script>jQuery(document).ready(function($) { $( '[id="input_<?php echo $this->id; ?>"]' ).buttonset(); });</script>
411 <?php
412 }
413 }
414
415 /**
416 * Load customizer conditional controler js file.
417 *
418 * @since 1.0.0
419 */
420
421 function betterdocs_customizer_condition() {
422 wp_enqueue_script( 'betterdocs-customize-condition',
423 BETTERDOCS_ADMIN_URL . 'assets/js/customizer-condition.js',
424 array(),
425 true
426 );
427 }
428 add_action( 'customize_controls_enqueue_scripts', 'betterdocs_customizer_condition' );
429
430 /**
431 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
432 *
433 * @since 1.0.0
434 */
435 function betterdocs_customize_preview_js() {
436 wp_enqueue_script( 'betterdocs-customizer',
437 BETTERDOCS_ADMIN_URL . 'assets/js/customizer.js',
438 array( 'customize-preview' ),
439 '',
440 true
441 );
442 }
443 add_action( 'customize_preview_init', 'betterdocs_customize_preview_js' );
444
445 ?>
446