1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Customizer Control: slider. |
4
|
|
|
* |
5
|
|
|
* Creates a jQuery slider control. |
6
|
|
|
* |
7
|
|
|
* @package Kirki |
8
|
|
|
* @subpackage Controls |
9
|
|
|
* @copyright Copyright (c) 2017, Aristeides Stathopoulos |
10
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
11
|
|
|
* @since 1.0 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
// Exit if accessed directly. |
15
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
16
|
|
|
exit; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Slider control (range). |
21
|
|
|
*/ |
22
|
|
|
class Kirki_Control_Slider extends Kirki_Control_Base { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The control type. |
26
|
|
|
* |
27
|
|
|
* @access public |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
public $type = 'kirki-slider'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Refresh the parameters passed to the JavaScript via JSON. |
34
|
|
|
* |
35
|
|
|
* @see WP_Customize_Control::to_json() |
36
|
|
|
*/ |
37
|
|
|
public function to_json() { |
38
|
|
|
parent::to_json(); |
39
|
|
|
|
40
|
|
|
$this->json['choices']['min'] = ( isset( $this->choices['min'] ) ) ? $this->choices['min'] : '0'; |
41
|
|
|
$this->json['choices']['max'] = ( isset( $this->choices['max'] ) ) ? $this->choices['max'] : '100'; |
42
|
|
|
$this->json['choices']['step'] = ( isset( $this->choices['step'] ) ) ? $this->choices['step'] : '1'; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* An Underscore (JS) template for this control's content (but not its container). |
47
|
|
|
* |
48
|
|
|
* Class variables for this control class are available in the `data` JS object; |
49
|
|
|
* export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
50
|
|
|
* |
51
|
|
|
* @see WP_Customize_Control::print_template() |
52
|
|
|
* |
53
|
|
|
* @access protected |
54
|
|
|
*/ |
55
|
|
|
protected function content_template() { |
56
|
|
|
?> |
57
|
|
|
<label> |
58
|
|
|
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
59
|
|
|
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
60
|
|
|
<div class="wrapper"> |
61
|
|
|
<input {{{ data.inputAttrs }}} type="range" min="{{ data.choices['min'] }}" max="{{ data.choices['max'] }}" step="{{ data.choices['step'] }}" value="{{ data.value }}" {{{ data.link }}} data-reset_value="{{ data.default }}" /> |
62
|
|
|
<div class="kirki_range_value"> |
63
|
|
|
<span class="value">{{ data.value }}</span> |
64
|
|
|
<# if ( data.choices['suffix'] ) { #> |
65
|
|
|
{{ data.choices['suffix'] }} |
66
|
|
|
<# } #> |
67
|
|
|
</div> |
68
|
|
|
</div> |
69
|
|
|
</label> |
70
|
|
|
<?php |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|