| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
if (isset($option)) { |
| 5 |
$option_type = isset( $option['type'] ) ? $option['type'] : ''; |
| 6 |
$option_id = isset( $option['id'] ) ? $this->settings_name . '[' . $option['id'] . ']' : ''; |
| 7 |
$option_css = sanitize_html_class( $this->settings_name . '_' . $option['id'] ); |
| 8 |
|
| 9 |
$option_options = isset( $option['options'] ) ? $option['options'] : ''; |
| 10 |
|
| 11 |
$attributes = array(); |
| 12 |
if ( isset( $option['attributes'] ) && is_array( $option['attributes'] ) ) { |
| 13 |
foreach ( $option['attributes'] as $attribute_name => $attribute_value ) { |
| 14 |
$attributes[] = esc_attr( $attribute_name ) . '="' . esc_attr( $attribute_value ) . '"'; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
$value = wpsight_get_option( $option['id'] ); |
| 19 |
if( !isset( $value ) && isset( $option['default'] ) ) $value = $option['default']; |
| 20 |
?> |
| 21 |
|
| 22 |
<div class="wpsight-settings-field wpsight-settings-field-<?php echo esc_attr( $option_type ); ?>"> |
| 23 |
<select id="setting-<?php echo esc_attr( $option_css ); ?>" class="regular-text" name="<?php echo esc_attr( $option_id ); ?>" <?php echo esc_attr( implode( ' ', $attributes ) ); ?>><?php |
| 24 |
foreach( $option_options as $key => $name ) |
| 25 |
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $value, $key, false ) . '>' . esc_html( $name ) . '</option>'; ?> |
| 26 |
</select> |
| 27 |
</div> |
| 28 |
|
| 29 |
<?php } ?> |
| 30 |
|