Kirki_Control_Switch   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A content_template() 0 17 1
1
<?php
2
/**
3
 * Customizer Control: switch.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Switch control (modified checkbox).
19
 */
20
class Kirki_Control_Switch extends Kirki_Control_Base {
21
22
	/**
23
	 * The control type.
24
	 *
25
	 * @access public
26
	 * @var string
27
	 */
28
	public $type = 'kirki-switch';
29
30
	/**
31
	 * An Underscore (JS) template for this control's content (but not its container).
32
	 *
33
	 * Class variables for this control class are available in the `data` JS object;
34
	 * export custom variables by overriding {@see WP_Customize_Control::to_json()}.
35
	 *
36
	 * @see WP_Customize_Control::print_template()
37
	 *
38
	 * @access protected
39
	 */
40
	protected function content_template() {
41
		?>
42
		<div class="switch<# if ( data.choices['round'] ) { #> round<# } #>">
43
			<span class="customize-control-title">
44
				{{{ data.label }}}
45
			</span>
46
			<# if ( data.description ) { #>
47
				<span class="description customize-control-description">{{{ data.description }}}</span>
48
			<# } #>
49
			<input class="screen-reader-text" {{{ data.inputAttrs }}} name="switch_{{ data.id }}" id="switch_{{ data.id }}" type="checkbox" value="{{ data.value }}" {{{ data.link }}}<# if ( '1' == data.value ) { #> checked<# } #> />
50
			<label class="switch-label" for="switch_{{ data.id }}">
51
				<span class="switch-on">
52
					<# data.choices.on = data.choices.on || '<?php esc_html_e( 'On', 'kirki' ); ?>' #>
53
					{{ data.choices.on }}
54
				</span>
55
				<span class="switch-off">
56
					<# data.choices.off = data.choices.off || '<?php esc_html_e( 'Off', 'kirki' ); ?>' #>
57
					{{ data.choices.off }}
58
				</span>
59
			</label>
60
		</div>
61
		<?php
62
	}
63
}
64