Passed
Push — develop ( d0c734...4216f4 )
by Aristeides
03:29
created

Kirki_Control_Checkbox::render_content()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 19
c 1
b 1
f 0
nc 4
nop 0
dl 0
loc 19
rs 9.4285
1
<?php
2
/**
3
 * Customizer Control: checkbox.
4
 *
5
 * Creates a new custom control.
6
 * Custom controls contains all background-related options.
7
 *
8
 * @package     Kirki
9
 * @subpackage  Controls
10
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
11
 * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
12
 * @since       3.0.26
13
 */
14
15
/**
16
 * Adds a checkbox control.
17
 *
18
 * @since 3.0.26
19
 */
20
class Kirki_Control_Checkbox extends Kirki_Control_Base {
21
22
	/**
23
	 * The control type.
24
	 *
25
	 * @access public
26
	 * @var string
27
	 */
28
	public $type = 'kirki-checkbox';
29
30
	/**
31
	 * Render the control's content.
32
	 * Verbatim copy from WP_Customize_Control->render_content.
33
	 *
34
	 * @since 3.0.26
35
	 */
36
	protected function render_content() {
37
		$input_id = '_customize-input-' . $this->id;
38
		$description_id = '_customize-description-' . $this->id;
39
		$describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
40
		?>
41
		<span class="customize-inside-control-row">
42
			<input
43
				id="<?php echo esc_attr( $input_id ); ?>"
44
				<?php echo $describedby_attr; ?>
45
				type="checkbox"
46
				value="<?php echo esc_attr( $this->value() ); ?>"
47
				<?php $this->link(); ?>
48
				<?php checked( $this->value() ); ?>
49
			/>
50
			<label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label>
51
			<?php if ( ! empty( $this->description ) ) : ?>
52
				<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
53
			<?php endif; ?>
54
		</span>
55
		<?php
56
	}
57
}
58