Completed
Push — master ( 372fed...3925eb )
by
unknown
03:37
created

Radio_Image_Field   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A template() 0 21 1
1
<?php
2
3
namespace Carbon_Fields\Field;
4
5
/**
6
 * Radio buttons field class.
7
 */
8
class Radio_Image_Field extends Select_Field {
9
	/**
10
	 * Underscore template of this field.
11
	 */
12
	public function template() {
13
		?>
14
		<# if (_.isEmpty(options)) { #>
15
			<em><?php esc_html_e( 'no options', 'carbon-fields' ); ?></em>
16
		<# } else { #>
17
			<div class="carbon-radio-image-list">
18
				<# _.each(options, function(option) { #>
19
					<div class="carbon-radio-image-item">
20
						<label>
21
							<input type="radio" name="{{{ name }}}" value="{{ option.value }}" {{{ option.value == value ? 'checked="checked"' : '' }}} />
22
23
							<figure class="carbon-radio-image-holder">
24
								<img src="{{{ option.name }}}" />
25
							</figure>
26
						</label>
27
					</div>
28
				<# }) #>
29
			</div>
30
		<# } #>
31
		<?php
32
	}
33
}
34