<?php
if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * @var string         $orbem_studio_key
 * @var boolean|string $orbem_studio_main_key
 * @var array          $orbem_studio_sub_value
 * @var boolean        $orbem_studio_required
 */

$orbem_studio_final_value = false === empty($orbem_studio_meta_values[$orbem_studio_key]) ? $orbem_studio_meta_values[$orbem_studio_key] : '';
$orbem_studio_final_value = false !== $orbem_studio_main_key && isset($orbem_studio_meta_values[$orbem_studio_main_key][$orbem_studio_key]) ? $orbem_studio_meta_values[$orbem_studio_main_key][$orbem_studio_key] : $orbem_studio_final_value;
?>
<p>
<?php if (false !== $orbem_studio_main_key): ?>
    <?php echo esc_html(ucfirst(str_replace(['explore-', '-'],['', ' '],$orbem_studio_key))); ?>
    <br>
<?php endif; ?>
<select
    name="<?php echo false === $orbem_studio_main_key ? esc_attr($orbem_studio_key) : esc_attr($orbem_studio_main_key . '[' . $orbem_studio_key. ']'); ?>"
    id="<?php echo false === $orbem_studio_main_key ? esc_attr($orbem_studio_key) : esc_attr($orbem_studio_main_key . '[' . $orbem_studio_key. ']'); ?>"
    <?php echo $orbem_studio_required ? ' required ' : ''; ?>
>
    <option value="" selected="selected">None</option>
    <?php if (true === is_array($orbem_studio_sub_value)): ?>
        <?php foreach($orbem_studio_sub_value as $orbem_studio_name => $orbem_studio_option):
            $orbem_studio_option_value = false !== isset($orbem_studio_option['name']) ? esc_html($orbem_studio_option['name']) : esc_html($orbem_studio_option);
            ?>
            <option value="<?php echo esc_html($orbem_studio_option_value); ?>" <?php selected($orbem_studio_final_value, $orbem_studio_option_value); ?>>
                <?php echo false !== isset($orbem_studio_option['name']) ? esc_html($orbem_studio_option['name']) . ' : ' : esc_html($orbem_studio_name); ?><?php echo false !== isset($orbem_studio_option['gender']) ? esc_html($orbem_studio_option['gender']) : '' ?>
            </option>
    <?php endforeach; endif; ?>
</select>
</p>