Kirki_Control_Dimension::content_template()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 3
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * Customizer Control: dimension
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       2.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * A text control with validation for CSS units.
19
 */
20
class Kirki_Control_Dimension extends Kirki_Control_Base {
21
22
	/**
23
	 * The control type.
24
	 *
25
	 * @access public
26
	 * @var string
27
	 */
28
	public $type = 'kirki-dimension';
29
30
	/**
31
	 * Enqueue control related scripts/styles.
32
	 *
33
	 * @access public
34
	 */
35
	public function enqueue() {
36
		parent::enqueue();
37
		wp_localize_script(
38
			'kirki-script', 'dimensionkirkiL10n', array(
0 ignored issues
show
Coding Style introduced by aristath
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
39
				'invalid-value' => esc_html__( 'Invalid Value', 'kirki' ),
40
			)
41
		);
42
	}
43
44
	/**
45
	 * An Underscore (JS) template for this control's content (but not its container).
46
	 *
47
	 * Class variables for this control class are available in the `data` JS object;
48
	 * export custom variables by overriding {@see WP_Customize_Control::to_json()}.
49
	 *
50
	 * @see WP_Customize_Control::print_template()
51
	 *
52
	 * @access protected
53
	 */
54
	protected function content_template() {
55
		?>
56
		<label class="customizer-text">
57
			<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
58
			<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
59
			<div class="input-wrapper">
60
				<# var val = ( data.value && _.isString( data.value ) ) ? data.value.replace( '%%', '%' ) : ''; #>
61
				<input {{{ data.inputAttrs }}} type="text" value="{{ val }}"/>
62
			</div>
63
		</label>
64
		<?php
65
	}
66
}
67