PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 2.2.1
Page Builder: Pagelayer – Drag and Drop website builder v2.2.1
2.2.1 2.2.0 2.1.9 2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 trunk 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 1.0.0 1.0.2 1.0.3 1.0.4 1.0.5 All 129 releases
pagelayer / main / customizer-controls.php

customizer-controls.php in Page Builder: Pagelayer – Drag and Drop website builder 2.2.1, at main/customizer-controls.php

786 lines 24.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //////////////////////////////////////////////////////////////
4 //===========================================================
5 // PAGELAYER
6 // Inspired by the DESIRE to be the BEST OF ALL
7 // ----------------------------------------------------------
8 // Started by: Pulkit Gupta
9 // Date: 23rd Jan 2017
10 // Time: 23:00 hrs
11 // Site: http://pagelayer.com/wordpress (PAGELAYER)
12 // ----------------------------------------------------------
13 // Please Read the Terms of use at http://pagelayer.com/tos
14 // ----------------------------------------------------------
15 //===========================================================
16 // (c)Pagelayer Team
17 //===========================================================
18 //////////////////////////////////////////////////////////////
19
20 // Are we being accessed directly ?
21 if(!defined('PAGELAYER_VERSION')) {
22 exit('Hacking Attempt !');
23 }
24
25 /**
26 * Override customize controls class
27 *
28 */
29 class Pagelayer_Customize_Control extends WP_Customize_Control{
30
31 public $show_filter = '';
32 public $li_class = '';
33
34 /**
35 * Refresh the parameters passed to the JavaScript via JSON.
36 *
37 * @see WP_Customize_Control::to_json()
38 */
39 public function to_json() {
40
41 parent::to_json();
42
43 if(!empty($this->show_filter)){
44 $this->json['show_filter'] = $this->show_filter;
45 }
46 }
47
48 protected function render() {
49 $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
50 $class = 'pagelayer-customize-control customize-control customize-control-' . $this->type;
51
52 $class .= ' '.$this->li_class;
53
54 printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) );
55 $this->render_content();
56 echo '</li>';
57 }
58 }
59
60 /**
61 * Padding control to separate general and style controls
62 *
63 */
64 class Pagelayer_Padding_Control extends Pagelayer_Customize_Control {
65
66 /**
67 * The type of control being rendered
68 */
69 public $type = 'pagelayer-padding-control';
70 public $responsive;
71 public $units;
72
73 /**
74 * Constructor
75 */
76 public function __construct( $manager, $id, $args = array(), $options = array() ) {
77 parent::__construct( $manager, $id, $args );
78
79 }
80
81 /**
82 * Render the control in the customizer
83 */
84 public function render_content() {
85
86 $units = (array) $this->units;
87
88 // Output the label and description if they were passed in.
89 if ( isset( $this->label ) && '' !== $this->label ) {
90 echo '<span class="customize-control-title pagelayer-customize-control-title">' . sanitize_text_field( $this->label );
91
92 if(!empty($this->responsive )){
93 echo '<span class="pagelayer-devices">
94 <button type="button" class="active-device" aria-pressed="true" data-device="desktop">
95 <i class="dashicons dashicons-desktop"></i>
96 </button>
97 <button type="button"aria-pressed="false" data-device="tablet">
98 <i class="dashicons dashicons-tablet"></i>
99 </button>
100 <button type="button" aria-pressed="false" data-device="mobile">
101 <i class="dashicons dashicons-smartphone"></i>
102 </button>
103 </span>';
104 }
105
106 if(!empty($units)){
107 ?>
108 <span class="pagelayer-units">
109 <input type="hidden" class="pagelayer-unit-input" value="<?php echo esc_attr($this->value('unit')); ?>" <?php $this->link('unit'); ?>></input>
110 <?php
111 foreach($units as $unit){
112 echo '<span data-unit="'.$unit.'"> '.$unit.' </span>';
113 }
114 ?>
115 </span>
116 <?php
117 }
118
119 echo '</span>';
120 }
121
122 $settings = array();
123
124 foreach ( $this->settings as $key => $setting ){
125 $key = str_replace(['_mobile', '_tablet'], '', $key);
126
127 if(in_array($key, $settings)){
128 continue;
129 }
130
131 $settings[] = $key;
132 }
133
134 $screens = array('');
135
136 if(!empty($this->responsive)){
137 $screens = array('', '_tablet', '_mobile');
138 }
139
140 echo '<div class="pagelayer-paddings-holder">';
141
142 foreach($screens as $screen){
143
144 $show_device = '';
145 if(count($screens) > 1){
146 $show_device = 'data-show-device="'.(empty($screen) ? '_desktop' : $screen).'"';
147 }
148
149 echo '<div class="pagelayer-control-padding" '.$show_device.'>';
150 foreach($settings as $setting){
151
152 // Skip units for responsive
153 if($setting == 'unit'){
154 continue;
155 }
156
157 $setting_name = $setting.$screen;
158 ?>
159 <input type="number" class="pagelayer-padding-input" value="<?php echo esc_attr($this->value($setting_name)); ?>" <?php $this->link($setting_name); ?>></input>
160 <?php
161 }
162
163 echo '<i class="dashicons dashicons-admin-links"></i></div>';
164 }
165
166 echo '</div>';
167 }
168 }
169
170 /**
171 * Typography control controls
172 *
173 */
174 class Pagelayer_typo_Control extends Pagelayer_Customize_Control {
175
176 /**
177 * The type of control being rendered
178 */
179 public $type = 'pagelayer-typo-control';
180 public $responsive;
181 public $style;
182
183 /**
184 * Constructor
185 */
186 public function __construct( $manager, $id, $args = array(), $options = array() ) {
187 parent::__construct( $manager, $id, $args );
188 }
189
190 /**
191 * Render the control in the customizer
192 */
193 public function render_content() {
194 global $pagelayer;
195
196 // Output the label and description if they were passed in.
197 if ( isset( $this->label ) && '' !== $this->label ) {
198 echo '<span class="customize-control-title">' . sanitize_text_field( $this->label ) .'</span>';
199 }
200
201 $settings = $pagelayer->font_settings;
202
203 echo '<div class="pagelayer-typography-holder">';
204
205 $global_font = $this->value('global-font');
206
207 if(!empty($global_font) && !isset($pagelayer->global_fonts[$global_font])){
208 $global_font = 'primary';
209 }
210
211 echo '<div class="pagelayer-control-typography">';
212 ?>
213 <div class="pagelayer-control-typo-holder <?php echo (!empty($global_font) ? 'pagelayer-global-on' : ''); ?>">
214 <div class="pagelayer-control-typo-icons-holder">
215 <span class="pagelayer-control-typo-icon dashicons dashicons-edit"></span>
216 </div>
217 <div class="pagelayer-control-typo">
218 <div class="pagelayer-global-setting-font">
219 <b><?php _e('Global Fonts'); ?></b>
220 <span class="pagelayer-control-global-typo-icon dashicons dashicons-admin-site-alt3"></span>
221 <span class="dashicons dashicons-admin-generic"></span>
222 <input class="pagelayer-global-font-input" type="hidden" <?php $this->link('global-font'); ?> value="<?php echo esc_attr($global_font); ?>" data-key="<?php echo esc_attr($global_font); ?>">
223
224 <div class="pagelayer-global-font-list"></div>
225 </div>
226 <?php foreach($settings as $sk => $sval){ ?>
227 <div class="pagelayer-control-typo-fields">
228 <label class="pagelayer-control-typo-fields-label"><?php echo $sval['label']?>
229 <?php
230 $screens = array('');
231 if(!empty($sval['responsive'])){
232
233 $screens = array('desktop', 'tablet', 'mobile');
234
235 ?>
236 <span class="pagelayer-devices">
237 <button type="button" class="active-device" aria-pressed="true" data-device="desktop">
238 <i class="dashicons dashicons-desktop"></i>
239 </button>
240 <button type="button"aria-pressed="false" data-device="tablet">
241 <i class="dashicons dashicons-tablet"></i>
242 </button>
243 <button type="button" aria-pressed="false" data-device="mobile">
244 <i class="dashicons dashicons-smartphone"></i>
245 </button>
246 </span>
247 <?php } ?>
248 <span class="pagelayer-typo-global-default dashicons dashicons-undo" title="<?php _e('Restore Global'); ?>"></span>
249 </label>
250 <?php
251 foreach($screens as $screen){
252
253 $show_device = '';
254 $field_name = $sk;
255
256 if(count($screens) > 1){
257 $show_device = 'data-show-device="_'.$screen.'"';
258 $field_name = $sk.($screen == 'desktop' ? '' : '_'.$screen);
259 }
260
261 $field_val = esc_attr($this->value($field_name));
262
263 if(isset($sval['choices'])){ ?>
264
265 <select name="<?php echo $field_name; ?>" <?php $this->link($field_name); ?> data-font-key="<?php echo $sk;?>" data-default-value="<?php echo $field_val; ?>" <?php echo $show_device; ?>>
266 <?php
267 // This add using js
268 //echo pagelayer_create_font_options($sval['choices'], $this->value($field_name));
269 ?>
270 </select>
271 <?php } else { ?>
272 <input name="<?php echo $field_name; ?>" type="number" <?php $this->link($field_name); ?> <?php echo $show_device; ?>>
273 <?php }
274 }
275 ?>
276 </div>
277 <?php }?>
278 </div>
279 </div>
280 <?php
281 echo '</div></div>';
282 }
283 }
284
285 /**
286 * Alpha Color Picker Custom Control
287 *
288 * @author Braad Martin <http://braadmartin.com>
289 * @license http://www.gnu.org/licenses/gpl-3.0.html
290 * @link https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker
291 */
292 class Pagelayer_Customize_Alpha_Color_Control extends Pagelayer_Customize_Control {
293 /**
294 * The type of control being rendered
295 */
296 public $type = 'pagelayer-alpha-color';
297 /**
298 * Add support for palettes to be passed in.
299 *
300 * Supported palette values are true, false, or an array of RGBa and Hex colors.
301 */
302 public $palette;
303 /**
304 * Add support for showing the opacity value on the slider handle.
305 */
306 public $show_opacity;
307 /**
308 * Enqueue our scripts and styles
309 */
310 public function enqueue() {
311 wp_enqueue_script( 'wp-color-picker' );
312 wp_enqueue_style( 'wp-color-picker' );
313 }
314 /**
315 * Render the control in the customizer
316 */
317 public function render_content() {
318 global $pagelayer;
319
320 $setvalue = $this->value();
321
322 // Process the palette
323 if ( is_array( $this->palette ) ) {
324 $palette = implode( '|', $this->palette );
325 } else {
326 // Default to true.
327 $palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true';
328 }
329
330 // Support passing show_opacity as string or boolean. Default to true.
331 $show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true';
332
333 // Output the label and description if they were passed in.
334 if ( isset( $this->label ) && '' !== $this->label ) {
335 echo '<span class="customize-control-title">' . sanitize_text_field( $this->label ) . '</span>';
336 }
337 if ( isset( $this->description ) && '' !== $this->description ) {
338 echo '<span class="description pagelayer-customize-description">' . sanitize_text_field( $this->description ) . '</span>';
339 } ?>
340
341 <span class="pagelayer-control-global-color-icon dashicons dashicons-admin-site-alt3"></span>
342 <div class="pagelayer-global-color-list">
343 <div class="pagelayer-global-setting-color">
344 <b>Global Colors</b>
345 <span class="dashicons dashicons-admin-generic"></span></div>
346 <?php
347 $gkey = '';
348 if( !empty($setvalue) && $setvalue[0] == '$'){
349 $gkey = substr($setvalue, 1);
350 $gkey = isset($pagelayer->global_colors[$gkey]) ? $gkey : 'primary';
351 }
352
353 foreach($pagelayer->global_colors as $cid => $color){
354
355 $active_class = '';
356 if($cid == $gkey){
357 $active_class = 'pagelayer-global-selected';
358 }
359 ?>
360 <div class="pagelayer-global-color-list-item <?php echo $active_class; ?>" data-global-id="<?php echo $cid; ?>">
361 <span class="pagelayer-global-color-pre" style="background:<?php echo $color['value']; ?>;"></span>
362 <span class="pagelayer-global-color-title"><?php echo $color['title'];?></span>
363 <span class="pagelayer-global-color-code"><?php echo $color['value']; ?></span>
364 </div>
365 <?php }?>
366 </div>
367 <input class="pagelayer-alpha-color-control" type="text" data-show-opacity="<?php echo $show_opacity; ?>" data-palette="<?php echo esc_attr( $palette ); ?>" data-default-color="<?php echo esc_attr( $this->settings['default']->default ); ?>" <?php $this->link(); ?> />
368 <?php
369
370 }
371 }
372
373 // Global color palette control
374 class Pagelayer_Color_Repeater_Control extends Pagelayer_Customize_Control {
375 /**
376 * The type of control being rendered
377 */
378 public $type = 'pagelayer-alpha-color';
379 /**
380 * Button labels
381 */
382 public $button_label = '';
383 /**
384 * Constructor
385 */
386 public function __construct( $manager, $id, $args = array(), $options = array() ) {
387 parent::__construct( $manager, $id, $args );
388
389 if(empty($this->button_label)){
390 $this->button_label = __( 'Add New Color', 'pagelayer' );
391 }
392 }
393
394 /**
395 * Render the control in the customizer
396 */
397 public function render_content() {
398
399 $values = $this->value();
400
401 $decode_values = json_decode($values, true);
402
403 $skip_keys = array('primary', 'secondary', 'text', 'accent');
404 ?>
405 <div class="pagelayer-color-palette-control">
406 <?php if( !empty( $this->label ) ) { ?>
407 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
408 <?php } ?>
409 <?php if( !empty( $this->description ) ) { ?>
410 <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
411 <?php } ?>
412 <input type="hidden" class="pagelayer-color-palette-data" <?php $this->link(); ?>>
413 <?php
414 foreach( $decode_values as $kk => $val){ ?>
415
416 <div class="pagelayer-color-holder">
417 <span class="pagelayer-color-title" contenteditable="true"><?php _e($val['title']); ?></span>
418 <span class="pagelayer-color-controls <?php echo (in_array($kk, $skip_keys)? 'pagelayer-prevent-delete' : ''); ?>">
419 <?php echo esc_attr($val['value']) ?>
420 </span>
421 <?php if(!in_array($kk, $skip_keys)){ ?>
422 <span class="customize-control-color-repeater-delete"><span class="dashicons dashicons-no-alt"></span></span>
423 <?php }?>
424 <input class="pagelayer-alpha-color-control" type="text" data-show-opacity="true" data-palette="true" data-default-color="<?php echo esc_attr($val['value']); ?>" data-id="<?php echo esc_attr($kk); ?>" data-title="<?php echo esc_attr($val['title']); ?>" value="<?php echo esc_attr($val['value']); ?>" />
425 </div>
426
427 <?php }?>
428 <button class="button customize-control-color-repeater-add" type="button"><?php echo $this->button_label; ?></button>
429 </div>
430 <?php
431 }
432 }
433
434 // Global color palette control
435 class Pagelayer_Font_Repeater_Control extends Pagelayer_Customize_Control {
436 /**
437 * The type of control being rendered
438 */
439 public $type = 'pagelayer-global-font';
440 /**
441 * Button labels
442 */
443 public $button_label = '';
444
445 /**
446 * Constructor
447 */
448 public function __construct( $manager, $id, $args = array(), $options = array() ) {
449 parent::__construct( $manager, $id, $args );
450
451 if(empty($this->button_label)){
452 $this->button_label = __( 'Add New Font', 'pagelayer' );
453 }
454 }
455
456 /**
457 * Render the control in the customizer
458 */
459 public function render_content() {
460 global $pagelayer;
461
462 $values = $this->value();
463
464 $decode_values = (array) json_decode($values, true);
465
466 $settings = $pagelayer->font_settings;
467
468 $skip_keys = array('primary', 'secondary', 'text', 'accent');
469 ?>
470 <div class="pagelayer-font-palette-control">
471 <?php if( !empty( $this->label ) ) { ?>
472 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
473 <?php } ?>
474 <?php if( !empty( $this->description ) ) { ?>
475 <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
476 <?php } ?>
477 <input type="hidden" class="pagelayer-font-palette-data" <?php $this->link(); ?>>
478 <?php
479 foreach( $decode_values as $kk => $val){ ?>
480
481 <div class="pagelayer-font-holder" data-id="<?php echo $kk; ?>">
482 <span class="pagelayer-font-title" contenteditable="true"><?php _e($val['title']); ?></span>
483 <?php if(!in_array($kk, $skip_keys)){ ?>
484 <span class="customize-control-font-repeater-delete"><span class="dashicons dashicons-no-alt"></span></span>
485 <?php }?>
486
487 <!-- Font Start -->
488 <div class="pagelayer-control-typo-holder">
489 <span class="pagelayer-control-typo-icon dashicons dashicons-edit"></span>
490 <div class="pagelayer-control-typo">
491
492 <?php foreach($settings as $sk => $sval){ ?>
493 <div class="pagelayer-control-typo-fields">
494 <label class="pagelayer-control-typo-fields-label"><?php echo $sval['label']?>
495
496 <?php
497 $screens = array('');
498 if(!empty($sval['responsive'])){
499
500 $screens = array('desktop', 'tablet', 'mobile');
501
502 ?>
503 <span class="pagelayer-devices">
504 <button type="button" class="active-device" aria-pressed="true" data-device="desktop">
505 <i class="dashicons dashicons-desktop"></i>
506 </button>
507 <button type="button"aria-pressed="false" data-device="tablet">
508 <i class="dashicons dashicons-tablet"></i>
509 </button>
510 <button type="button" aria-pressed="false" data-device="mobile">
511 <i class="dashicons dashicons-smartphone"></i>
512 </button>
513 </span>
514 <?php } ?>
515 </label>
516
517 <?php
518 foreach($screens as $screen){
519
520 $show_device = '';
521 $field_name = $sk;
522 $field_val = (empty($val['value'][$sk]) ? '' : $val['value'][$sk]);
523
524 if(count($screens) > 1){
525 $field_name = $sk.'['.$screen.']';
526 $show_device = 'data-show-device="_'.$screen.'"';
527
528 if(is_array($field_val)){
529 $field_val = (empty($field_val[$screen]) ? '' : $field_val[$screen]);
530 }
531 }
532
533 if(isset($sval['choices'])){ ?>
534 <select name="<?php echo $field_name; ?>" data-font-key="<?php echo $sk;?>" data-default-value="<?php echo $field_val; ?>" <?php echo $show_device;?>>
535 <?php
536 // This add using js
537 //echo pagelayer_create_font_options($sval['choices'], $val['value'][$sk]);
538 ?>
539 </select>
540 <?php } else { ?>
541 <input type="number" name="<?php echo $field_name; ?>" value="<?php echo $field_val; ?>" <?php echo $show_device;?>>
542 <?php
543 }
544 }
545 ?>
546 </div>
547 <?php } ?>
548
549 </div>
550 </div>
551 <!-- Font End -->
552 </div>
553
554 <?php }?>
555 <button class="button customize-control-font-repeater-add" type="button"><?php echo $this->button_label; ?></button>
556 </div>
557 <?php
558 }
559 }
560
561 /**
562 * Customize control
563 *
564 */
565 class Pagelayer_Custom_Control extends Pagelayer_Customize_Control {
566
567 /**
568 * The type of control being rendered
569 */
570 public $type = 'pagelayer-customize-control';
571 public $responsive;
572 public $units;
573
574 /**
575 * Constructor
576 */
577 public function __construct( $manager, $id, $args = array(), $options = array() ) {
578 parent::__construct( $manager, $id, $args );
579 }
580
581 /**
582 * Render the control in the customizer
583 */
584 public function render_content() {
585
586 $units = $this->units;
587 $input_id = '_customize-input-' . $this->id;
588 $description_id = '_customize-description-' . $this->id;
589 $describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
590 switch ( $this->type ) {
591 case 'checkbox':
592 ?>
593 <span class="pagelayer-customize-inside-control-row">
594 <label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label>
595 <input
596 id="<?php echo esc_attr( $input_id ); ?>"
597 class="pagelayer-customize-checkbox"
598 <?php echo $describedby_attr; ?>
599 type="checkbox"
600 value="<?php echo esc_attr( $this->value() ); ?>"
601 <?php $this->link(); ?>
602 <?php checked( $this->value() ); ?>
603 />
604 <?php if ( ! empty( $this->description ) ) : ?>
605 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
606 <?php endif; ?>
607 </span>
608 <?php
609 break;
610 case 'radio':
611 if ( empty( $this->choices ) ) {
612 return;
613 }
614
615 $name = '_customize-radio-' . $this->id;
616 ?>
617 <?php if ( ! empty( $this->label ) ) : ?>
618 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
619 <?php endif; ?>
620 <?php if ( ! empty( $this->description ) ) : ?>
621 <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
622 <?php endif; ?>
623 <span class="pagelayer-customize-inside-control-row">
624 <?php foreach ( $this->choices as $value => $label ) : ?>
625
626 <input
627 id="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"
628 class="pagelayer-customize-radio"
629 type="radio"
630 <?php echo $describedby_attr; ?>
631 value="<?php echo esc_attr( $value ); ?>"
632 name="<?php echo esc_attr( $name ); ?>"
633 <?php $this->link(); ?>
634 <?php checked( $this->value(), $value ); ?>
635 data-label="<?php echo esc_html( $label ); ?>"
636 />
637 <?php endforeach; ?>
638 </span>
639 <?php
640 break;
641 case 'divider':
642 echo '<hr class="pagelayer-customize-divider">';
643 break;
644 case 'pl_slider':
645 ?>
646 <div class="pagelayer-slider-custom-control">
647 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?>
648 <?php if(!empty($this->responsive )){?>
649 <span class="pagelayer-devices">
650 <button type="button" class="active-device" aria-pressed="true" data-device="desktop">
651 <i class="dashicons dashicons-desktop"></i>
652 </button>
653 <button type="button"aria-pressed="false" data-device="tablet">
654 <i class="dashicons dashicons-tablet"></i>
655 </button>
656 <button type="button" aria-pressed="false" data-device="mobile">
657 <i class="dashicons dashicons-smartphone"></i>
658 </button>
659 </span>
660 <?php } ?>
661 </span>
662 <?php
663 if(!empty($units)){
664 ?>
665 <span class="pagelayer-units">
666 <input type="hidden" class="pagelayer-unit-input" value="<?php echo esc_attr($this->value('unit')); ?>" <?php $this->link('unit'); ?>></input>
667 <?php
668 foreach($units as $unit){
669 echo '<span data-unit="'.$unit.'"> '.$unit.' </span>';
670 }
671 ?>
672 </span>
673 <?php }
674
675 $screens = array('');
676 $set_link = 'slider';
677
678 if(!empty($this->responsive)){
679 $screens = array('desktop' => '_desktop', 'tablet' => '_tablet', 'mobile' => '_mobile');
680 }
681
682 foreach($screens as $screen => $_screen){
683
684 $show_device = empty($_screen)? '' : 'data-show-device="'.$_screen.'"';
685
686 echo '<div class="pagelayer-control-typography" '.$show_device.'>';
687 ?>
688 <input class="pagelayer-slider" type="range" min="<?php echo esc_attr( $this->input_attrs['min'] ); ?>" max="<?php echo esc_attr( $this->input_attrs['max'] ); ?>" step="<?php echo esc_attr( $this->input_attrs['step'] ); ?>" value="<?php echo esc_attr( $this->value($set_link.$_screen) ); ?>" />
689 <input type="number" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value($set_link.$_screen) ); ?>" class="customize-control-slider-value" <?php $this->link($set_link.$_screen); ?> min="<?php echo esc_attr( $this->input_attrs['min'] ); ?>" max="<?php echo esc_attr( $this->input_attrs['max'] ); ?>" step="<?php echo esc_attr( $this->input_attrs['step'] ); ?>"/>
690
691 </div>
692 <?php } ?>
693 </div>
694 <?php
695 break;
696 }
697 }
698 }
699
700 /**
701 * Switch sanitization
702 *
703 * @param string Switch value
704 * @return integer Sanitized value
705 */
706 if ( ! function_exists( 'pagelayer_switch_sanitization' ) ) {
707 function pagelayer_switch_sanitization( $input ) {
708 if ( true === $input ) {
709 return 1;
710 } else {
711 return 0;
712 }
713 }
714 }
715
716 /**
717 * Alpha Color (Hex & RGBa) sanitization
718 *
719 * @param string Input to be sanitized
720 * @return string Sanitized input
721 */
722 if ( ! function_exists( 'pagelayer_hex_rgba_sanitization' ) ) {
723 function pagelayer_hex_rgba_sanitization( $input, $setting ) {
724 if ( empty( $input ) || is_array( $input ) ) {
725 return $setting->default;
726 }
727
728 if ( false === strpos( $input, 'rgba' ) ) {
729 // If string doesn't start with 'rgba' then santize as hex color
730 $input = sanitize_hex_color( $input );
731 } else {
732 // Sanitize as RGBa color
733 $input = str_replace( ' ', '', $input );
734 sscanf( $input, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
735 $input = 'rgba(' . pagelayer_in_range( $red, 0, 255 ) . ',' . pagelayer_in_range( $green, 0, 255 ) . ',' . pagelayer_in_range( $blue, 0, 255 ) . ',' . pagelayer_in_range( $alpha, 0, 1 ) . ')';
736 }
737 return $input;
738 }
739 }
740
741 /**
742 * Only allow values between a certain minimum & maxmium range
743 *
744 * @param number Input to be sanitized
745 * @return number Sanitized input
746 */
747 if ( ! function_exists( 'pagelayer_in_range' ) ) {
748 function pagelayer_in_range( $input, $min, $max ){
749 if ( $input < $min ) {
750 $input = $min;
751 }
752 if ( $input > $max ) {
753 $input = $max;
754 }
755 return $input;
756 }
757 }
758
759 // Create font options
760 function pagelayer_create_font_options( $args, $set ){
761 $options = '';
762 foreach( $args as $value => $label ){
763 $_value = $value;
764
765 if(is_numeric($value)){
766 $_value = $label;
767 }
768
769 // Single item
770 if(is_string($label)){
771 $options .= pagelayer_sel_option( $_value, $label, $set);
772 continue;
773 }
774 if( $value == 'default'){
775 $options .= pagelayer_sel_option( '', $value, $set);
776 continue;
777 }
778
779 $options .= '<optgroup label="'. $value .'">';
780 $options .= pagelayer_create_font_options($label, $set);
781 $options .= '</optgroup>';
782 }
783
784 return $options;
785 }
786