Completed
Push — add/stats-package ( 873a22...c3aabb )
by
unknown
230:03 queued 222:25
created

Label_Control::render_content()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 0
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
/**
3
 * A label-only Customizer control for use with Jetpack Search configuration
4
 *
5
 * @package jetpack
6
 * @since 8.6.0
7
 */
8
9
/**
10
 * Label Control class.
11
 */
12
class Label_Control extends WP_Customize_Control {
13
	/**
14
	 * Enqueue styles related to this control.
15
	 */
16
	public function enqueue() {
17
		require_once dirname( dirname( __FILE__ ) ) . '/class.jetpack-search-helpers.php';
18
		$style_relative_path = 'modules/search/customize-controls/class-label-control.css';
19
		$style_version       = Jetpack_Search_Helpers::get_asset_version( $style_relative_path );
20
		$style_path          = plugins_url( $style_relative_path, JETPACK__PLUGIN_FILE );
21
		wp_enqueue_style( 'jetpack-instant-search', $style_path, array(), $style_version );
22
	}
23
24
	/**
25
	 * Override rendering for custom class name; omit element ID.
26
	 */
27
	protected function render() {
28
		echo '<li class="customize-control customize-label-control">';
29
		$this->render_content();
30
		echo '</li>';
31
	}
32
33
	/**
34
	 * Override content rendering.
35
	 */
36
	protected function render_content() {
37
		if ( ! empty( $this->label ) ) : ?>
38
			<label class="customize-control-title">
39
				<?php echo esc_html( $this->label ); ?>
40
			</label>
41
		<?php endif; ?>
42
		<?php if ( ! empty( $this->description ) ) : ?>
43
			<span class="description customize-control-description">
44
				<?php echo esc_html( $this->description ); ?>
45
			</span>
46
			<?php
47
		endif;
48
	}
49
}
50