Kirki_Control_Multicolor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 23
dl 0
loc 41
rs 10
c 2
b 1
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A to_json() 0 3 1
A content_template() 0 3 1
1
<?php
2
/**
3
 * Customizer Control: multicolor.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       2.2.7
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Multicolor control.
19
 */
20
class Kirki_Control_Multicolor extends Kirki_Control_Base {
21
22
	/**
23
	 * The control type.
24
	 *
25
	 * @access public
26
	 * @var string
27
	 */
28
	public $type = 'kirki-multicolor';
29
30
	/**
31
	 * Enable/Disable Alpha channel on color pickers
32
	 *
33
	 * @access public
34
	 * @var boolean
35
	 */
36
	public $alpha = true;
37
38
	/**
39
	 * Refresh the parameters passed to the JavaScript via JSON.
40
	 *
41
	 * @access public
42
	 */
43
	public function to_json() {
44
		parent::to_json();
45
		$this->json['alpha'] = (bool) $this->alpha;
46
	}
47
48
	/**
49
	 * An Underscore (JS) template for this control's content (but not its container).
50
	 *
51
	 * Class variables for this control class are available in the `data` JS object;
52
	 * export custom variables by overriding {@see WP_Customize_Control::to_json()}.
53
	 *
54
	 * @see WP_Customize_Control::print_template()
55
	 *
56
	 * @access protected
57
	 */
58
	protected function content_template() {
59
		?>
60
		<span class="customize-control-title">
61
			{{{ data.label }}}
62
		</span>
63
		<# if ( data.description ) { #>
64
			<span class="description customize-control-description">{{{ data.description }}}</span>
65
		<# } #>
66
		<div class="multicolor-group-wrapper">
67
			<# for ( key in data.choices ) { #>
68
				<# if ( 'irisArgs' !== key ) { #>
69
					<div class="multicolor-single-color-wrapper">
70
						<input {{{ data.inputAttrs }}} id="{{ data.id }}-{{ key }}" type="text" data-palette="{{ data.palette }}" data-default-color="{{ data.default[ key ] }}" data-alpha="{{ data.alpha }}" value="{{ data.value[ key ] }}" class="kirki-color-control color-picker multicolor-index-{{ key }}" data-label="<# if ( data.choices[ key ] ) { #>{{ data.choices[ key ] }}<# } else { #>{{ key }}<# } #>" />
71
					</div>
72
				<# } #>
73
			<# } #>
74
		</div>
75
		<input class="multicolor-hidden-value" type="hidden" {{{ data.link }}}>
76
		<?php
77
	}
78
}
79