<?php
$attributes = '';
if ($args['id']) {
    $attributes .= ' id="' . $args['id'] . '" ';
}

if ($args['name']) {
    $attributes .= ' name="' . $args['name'] . '" ';
}

if ($args['class']) {
    $attributes .= ' class="regular-text ' . $args['class'] . '" ';
} else {
    $attributes .= ' class="regular-text" ';
}

if ($args['style']) {
    $attributes .= ' style="' . $args['style'] . '" ';
}
if ($args['required']) {
    $attributes .= ' required';
}

$conditional = salesloo_field_get_conditional_data($args);

?>
<div class="salesloo-field <?php echo $args['direction']; ?>" <?php echo implode(' ', $conditional); ?>>
    <div class="salesloo-field-label" style="width: 100%">
        <label><?php echo $args['label']; ?></label>
    </div>
    <div class="salesloo-field-input">
        <div class="salesloo-field__select">
            <?php echo $args['before']; ?>
            <select <?php echo $attributes; ?>>
                <?php foreach ((array)$args['options'] as $value => $label) {
                    $checked = $args['value'] == $value ? ' selected="selected"' : '';
                    echo '<option value="' . $value . '"' . $checked . '>' . $label . '</option>';
                } ?>
            </select>
            <?php echo $args['after']; ?>
        </div>
        <p class="description"><?php echo $args['description']; ?></p>
    </div>
</div>