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