1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Flynt\Customizer; |
4
|
|
|
|
5
|
|
|
class RangeControl extends \WP_Customize_Control |
6
|
|
|
{ |
7
|
|
|
public $type = 'flynt_range'; |
8
|
|
|
public $unit = ''; |
9
|
|
|
public $options = []; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Refresh the parameters passed to the JavaScript via JSON. |
13
|
|
|
*/ |
14
|
|
|
public function to_json() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
15
|
|
|
{ |
16
|
|
|
parent::to_json(); |
17
|
|
|
$this->json['id'] = $this->id; |
|
|
|
|
18
|
|
|
$this->json['link'] = $this->get_link(); |
|
|
|
|
19
|
|
|
$this->json['value'] = $this->value(); |
|
|
|
|
20
|
|
|
$this->json['unit'] = $this->unit; |
|
|
|
|
21
|
|
|
$this->json['options'] = $this->options; |
|
|
|
|
22
|
|
|
$this->json['default'] = $this->default ?? $this->setting->default; |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Don't render the control content from PHP, as it's rendered via JS on load. |
27
|
|
|
*/ |
28
|
|
|
public function render_content() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
29
|
|
|
{ |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Render a JS template for control display. |
34
|
|
|
*/ |
35
|
|
|
public function content_template() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
36
|
|
|
{ |
37
|
|
|
?> |
38
|
|
|
<# if ( data.label ) { #><label for="{{{ data.id }}}" class="customize-control-title">{{{ data.label }}} ({{{ data.unit }}})</label><# } #> |
39
|
|
|
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
40
|
|
|
|
41
|
|
|
<div class="customize-control-notifications-container"></div> |
42
|
|
|
|
43
|
|
|
<div class="customize-control-content"> |
44
|
|
|
<div class="flynt-range-field"> |
45
|
|
|
<input |
46
|
|
|
type="range" |
47
|
|
|
class="flynt-range flynt-range-slider" |
48
|
|
|
data-change="number" |
49
|
|
|
value="{{{ data.value }}}" |
50
|
|
|
{{{ data.link }}} |
51
|
|
|
<# _.each(data.options, function(value, key) { #> |
52
|
|
|
{{{ key }}}="{{ value }}" |
53
|
|
|
<# }); #> |
54
|
|
|
> |
55
|
|
|
<input |
56
|
|
|
type="number" |
57
|
|
|
class="flynt-range flynt-range-number" |
58
|
|
|
data-change="slider" |
59
|
|
|
value="{{{ data.value }}}" |
60
|
|
|
id="{{{ data.id }}}" |
61
|
|
|
{{{ data.link }}} |
62
|
|
|
<# _.each(data.options, 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
|
|
|
|
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.