Completed
Push — develop ( 4910e3...56d9e6 )
by
unknown
04:13
created

Wordlift_Metabox_Field_Select::html_input()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 15

Duplication

Lines 8
Ratio 36.36 %

Importance

Changes 0
Metric Value
cc 2
eloc 15
nc 2
nop 1
dl 8
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * Metaxboxes: Integer Field.
4
 *
5
 * This file defines the Wordlift_Metabox_Field_Select class which displays select field
6
 * in WordPress' entity posts pages.
7
 *
8
 * @since   3.18.0
9
 * @package Wordlift
10
 */
11
12
/**
13
 * The Wordlift_Metabox_Field_Select class extends {@link WL_Metabox_Field} and provides
14
 * support for select fields.
15
 *
16
 * @since   3.18.0
17
 * @package Wordlift
18
 */
19
class Wordlift_Metabox_Field_Select extends WL_Metabox_Field {
20
21
	/**
22
	 * @inheritdoc
23
	 */
24
	public function html_input( $text ) {
25
		@ob_start();
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
26
		?>
27
		<div class="wl-input-wrapper">
28
29
			<select name="wl_metaboxes[<?php echo $this->meta_name ?>]" id="<?php echo esc_attr( $this->meta_name ); ?>" style="width:88%;">
30 View Code Duplication
				<?php foreach ( $this->raw_custom_field['options'] as $option => $label ): ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
32
					<option value="<?php echo esc_attr( $option ); ?>" <?php selected( $text, $option ); ?>>
33
						<?php echo $label; ?>
34
					</option>
35
36
				<?php endforeach ?>
37
			</select>
38
39
			<div class="wl-input-notice"></div>
40
		</div>
41
		<?php
42
43
		$html = ob_get_clean();
44
		return $html;
45
	}
46
47
}
48