Kirki_Controls   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 54
rs 10
c 1
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A underscore_templates() 0 6 3
A __construct() 0 5 2
1
<?php
2
/**
3
 * Customizer Controls Init.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       3.0.17
10
 */
11
12
/**
13
 * Controls.
14
 */
15
class Kirki_Controls {
16
17
	/**
18
	 * An array of templates to load.
19
	 *
20
	 * @access private
21
	 * @since 3.0.17
22
	 * @var array
23
	 */
24
	private $templates = array(
25
		'code',
26
		'color',
27
		'generic',
28
		'image',
29
		'number',
30
		'radio',
31
		'select',
32
		'textarea',
33
	);
34
35
	/**
36
	 * Path to controls views.
37
	 *
38
	 * @access private
39
	 * @since 3.0.17
40
	 * @var string
41
	 */
42
	private $views_path;
43
44
	/**
45
	 * Constructor.
46
	 *
47
	 * @access public
48
	 * @since 3.0.17
49
	 */
50
	public function __construct() {
51
		if ( ! $this->views_path ) {
52
			$this->views_path = wp_normalize_path( dirname( KIRKI_PLUGIN_FILE ) . '/controls/views/' );
53
		}
54
		add_action( 'customize_controls_print_footer_scripts', array( $this, 'underscore_templates' ) );
55
	}
56
57
	/**
58
	 * Adds underscore.js templates to the footer.
59
	 *
60
	 * @access public
61
	 * @since 3.0.17
62
	 */
63
	public function underscore_templates() {
64
		foreach ( $this->templates as $template ) {
65
			if ( file_exists( $this->views_path . $template . '.php' ) ) {
66
				echo '<script type="text/html" id="tmpl-kirki-input-' . esc_attr( $template ) . '">';
67
				include $this->views_path . $template . '.php';
68
				echo '</script>';
69
			}
70
		}
71
	}
72
}
73