Completed
Push — develop ( d513ba...161245 )
by David
05:02 queued 32s
created

Wordlift_UI_Service::print_template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4286
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/**
4
 * Provides functions to draw the UI.
5
 *
6
 * @since 3.2.0
7
 */
8
class Wordlift_UI_Service {
9
10
	/**
11
	 * The button element HTML code.
12
	 *
13
	 * @since 3.2.0
14
	 */
15
	const BUTTON_HTML = '<a id="%s" class="button wl-button">%s</a>';
16
17
	/**
18
	 * The template HTML code.
19
	 *
20
	 * @since 3.2.0
21
	 */
22
	const TEMPLATE_HTML = '<script id="%s" type="text/template">%s</script>';
23
24
	/**
25
	 * Get the button HTML.
26
	 *
27
	 * @since 3.2.0
28
	 *
29
	 * @param string $element_id The button element id.
30
	 * @param string $label The button (translated) label.
31
	 *
32
	 * @return string The button HTML code.
33
	 */
34
	public function get_button_html( $element_id, $label ) {
35
36
		return sprintf( self::BUTTON_HTML, $element_id, esc_html( $label ) );
37
	}
38
39
	/**
40
	 * Echo the button HTML.
41
	 *
42
	 * @since 3.2.0
43
	 *
44
	 * @param string $element_id The button element id.
45
	 * @param string $label The button (translated) label.
46
	 *
47
	 * @return string The button HTML code.
48
	 */
49
	public function print_button( $element_id, $label ) {
50
51
		echo( $this->get_button_html( $element_id, $label ) );
52
53
	}
54
55
	/**
56
	 * Get the HTML code for a template tag.
57
	 *
58
	 * @since 3.2.0
59
	 *
60
	 * @param string $element_id The element id.
61
	 * @param string $body The element content.
62
	 *
63
	 * @return string The HTML code.
64
	 */
65
	public function get_template_html( $element_id, $body ) {
66
67
		return sprintf( self::TEMPLATE_HTML, $element_id, $body );
68
	}
69
70
	/**
71
	 * Echo the HTML code for a template tag.
72
	 *
73
	 * @since 3.2.0
74
	 *
75
	 * @param string $element_id The element id.
76
	 * @param string $body The element content.
77
	 *
78
	 * @return string The HTML code.
79
	 */
80
	public function print_template( $element_id, $body ) {
81
82
		echo( $this->get_template_html( $element_id, $body ) );
83
84
	}
85
86
}
87