|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Flynt\Customizer\Range; |
|
4
|
|
|
|
|
5
|
|
|
class Control extends \WP_Customize_Control |
|
6
|
|
|
{ |
|
7
|
|
|
public $type = 'flynt-range'; |
|
8
|
|
|
public $unit = ''; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Refresh the parameters passed to the JavaScript via JSON. |
|
12
|
|
|
* |
|
13
|
|
|
* @return array Array of parameters passed to the JavaScript. |
|
14
|
|
|
*/ |
|
15
|
|
|
public function json() { |
|
16
|
|
|
$json = parent::json(); |
|
17
|
|
|
$json['id'] = $this->id; |
|
18
|
|
|
$json['link'] = $this->get_link(); |
|
19
|
|
|
$json['value'] = $this->value(); |
|
20
|
|
|
$json['unit'] = $this->unit; |
|
21
|
|
|
$json['input_attrs'] = $this->input_attrs; |
|
22
|
|
|
$json['default'] = $this->default ?? $this->setting->default; |
|
|
|
|
|
|
23
|
|
|
return $json; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Don't render the control content from PHP, as it's rendered via JS on load. |
|
28
|
|
|
*/ |
|
29
|
|
|
public function render_content() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
30
|
|
|
{ |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Render a JS template for control display. |
|
35
|
|
|
*/ |
|
36
|
|
|
public function content_template() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
37
|
|
|
{ |
|
38
|
|
|
?> |
|
39
|
|
|
<# if ( data.label ) { #><label for="{{{ data.id }}}" class="customize-control-title">{{{ data.label }}} ({{{ data.unit }}})</label><# } #> |
|
40
|
|
|
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
|
41
|
|
|
|
|
42
|
|
|
<div class="customize-control-notifications-container"></div> |
|
43
|
|
|
|
|
44
|
|
|
<div class="customize-control-content"> |
|
45
|
|
|
<div class="flynt-range-field"> |
|
46
|
|
|
<input |
|
47
|
|
|
type="range" |
|
48
|
|
|
data-change="number" |
|
49
|
|
|
value="{{{ data.value }}}" |
|
50
|
|
|
{{{ data.link }}} |
|
51
|
|
|
<# _.each(_.extend({'class': 'flynt-range flynt-range-slider'}, data.input_attrs), function(value, key) { #> |
|
52
|
|
|
{{{ key }}}="{{ value }}" |
|
53
|
|
|
<# }); #> |
|
54
|
|
|
> |
|
55
|
|
|
<input |
|
56
|
|
|
type="number" |
|
57
|
|
|
data-change="slider" |
|
58
|
|
|
value="{{{ data.value }}}" |
|
59
|
|
|
id="{{{ data.id }}}" |
|
60
|
|
|
{{{ data.link }}} |
|
61
|
|
|
<# _.each(_.extend({'class': 'flynt-range flynt-range-number'}, data.input_attrs), function(value, key) { #> |
|
62
|
|
|
{{{ key }}}="{{ value }}" |
|
63
|
|
|
<# }); #> |
|
64
|
|
|
> |
|
65
|
|
|
<button type="button" class="flynt-range-reset button button-secondary" data-default="{{{ data.default }}}"><?php esc_html_e('Default', 'flynt'); ?></button> |
|
66
|
|
|
</div> |
|
67
|
|
|
</div> |
|
68
|
|
|
|
|
69
|
|
|
<?php |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|