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 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 | $this->json['choices'] = wp_parse_args( |
||
40 | $this->json['choices'], array( |
||
0 ignored issues
–
show
|
|||
41 | 'min' => '0', |
||
42 | 'max' => '100', |
||
43 | 'step' => '1', |
||
44 | 'suffix' => '', |
||
45 | ) |
||
46 | ); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * An Underscore (JS) template for this control's content (but not its container). |
||
51 | * |
||
52 | * Class variables for this control class are available in the `data` JS object; |
||
53 | * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
||
54 | * |
||
55 | * @see WP_Customize_Control::print_template() |
||
56 | * |
||
57 | * @access protected |
||
58 | */ |
||
59 | protected function content_template() { |
||
60 | ?> |
||
61 | <label> |
||
62 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
||
63 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
||
64 | <div class="wrapper"> |
||
65 | <input {{{ data.inputAttrs }}} type="range" min="{{ data.choices['min'] }}" max="{{ data.choices['max'] }}" step="{{ data.choices['step'] }}" value="{{ data.value }}" {{{ data.link }}} /> |
||
66 | <span class="slider-reset dashicons dashicons-image-rotate"><span class="screen-reader-text"><?php esc_html_e( 'Reset', 'kirki' ); ?></span></span> |
||
67 | <span class="value"> |
||
68 | <input {{{ data.inputAttrs }}} type="text"/> |
||
69 | <span class="suffix">{{ data.choices['suffix'] }}</span> |
||
70 | </span> |
||
71 | </div> |
||
72 | </label> |
||
73 | <?php |
||
74 | } |
||
75 | } |
||
76 |
For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this: