<?php
namespace Wpupgrader\Libraries\WordPress\Plugins\Core\Settings\Page\Callback;

use Wpupgrader\Libraries\WordPress\Plugins\Core\Settings\Page\Callback;

class Select extends Callback
{
    public function callbackAction()
    {
        $options = $this->getOptions();

        $name = \esc_attr($this->getNameString());
        $id = $this->getIdString() ? " id='".\esc_attr($this->getIdString())."'" : " id='$name'";
        $output = "<select name='{$name}'{$id} class='gdprc-consent-dropdown'>\n";
        $output .= "\t<option value=''>".\__("- Inherit -", 'gdprc_consent')."</option>\n";

        foreach ($options as $option => $label) {
            $_selected = \selected($option, $this->getValue(), false);
            $output .= "\t<option value='{$option}'{$_selected}>".\esc_html($label)."</option>\n";
        }
        $output .= "</select>";

        echo $output;
        echo $this->getDescription();
    }
}