Code Duplication    Length = 32-32 lines in 2 locations

includes/fields-api-controls.php 2 locations

@@ 90-121 (lines=32) @@
87
 *
88
 * @see WP_Fields_API_Control
89
 */
90
class WP_Fields_API_Multi_Checkbox_Control extends WP_Fields_API_Control {
91
92
	/**
93
	 * {@inheritdoc}
94
	 */
95
	public function render_content() {
96
97
		if ( empty( $this->choices ) ) {
98
			return;
99
		}
100
101
		$name = '_fields-checkbox-' . $this->id;
102
103
		if ( ! empty( $this->label ) ) : ?>
104
			<span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span>
105
		<?php endif;
106
		if ( ! empty( $this->description ) ) : ?>
107
			<span class="description fields-control-description"><?php echo $this->description ; ?></span>
108
		<?php endif;
109
110
		foreach ( $this->choices as $value => $label ) :
111
			?>
112
			<label>
113
				<input type="checkbox" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?> />
114
				<?php echo esc_html( $label ); ?><br/>
115
			</label>
116
			<?php
117
		endforeach;
118
119
	}
120
121
}
122
123
/**
124
 * Fields API Radio Control class.
@@ 128-159 (lines=32) @@
125
 *
126
 * @see WP_Fields_API_Control
127
 */
128
class WP_Fields_API_Radio_Control extends WP_Fields_API_Control {
129
130
	/**
131
	 * {@inheritdoc}
132
	 */
133
	public function render_content() {
134
135
		if ( empty( $this->choices ) ) {
136
			return;
137
		}
138
139
		$name = '_fields-radio-' . $this->id;
140
141
		if ( ! empty( $this->label ) ) : ?>
142
			<span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span>
143
		<?php endif;
144
		if ( ! empty( $this->description ) ) : ?>
145
			<span class="description fields-control-description"><?php echo $this->description ; ?></span>
146
		<?php endif;
147
148
		foreach ( $this->choices as $value => $label ) :
149
			?>
150
			<label>
151
				<input type="radio" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?> />
152
				<?php echo esc_html( $label ); ?><br/>
153
			</label>
154
			<?php
155
		endforeach;
156
157
	}
158
159
}
160
161
/**
162
 * Fields API Select Control class.