<?php
/**
 * Customizer Button Control
 *
 * @package Flavor
 * @since 3.0.2
 */

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Button Control
 */
class Paws_And_Care_Customize_Button_Control extends Paws_And_Care_Customize_Base_Control
{
    /**
     * Control type
     *
     * @var string
     */
    public $type = 'button';

    /**
     * Button text
     *
     * @var string
     */
    public $button_text = '';

    /**
     * Button class (for styling)
     *
     * @var string
     */
    public $button_class = 'button button-secondary';

    /**
     * Custom data attributes
     *
     * @var array
     */
    public $input_attrs = array();

    /**
     * Render content
     */
    public function render_content()
    {
        $button_class = !empty($this->button_class) ? $this->button_class : 'button button-secondary';
        $button_text = !empty($this->button_text) ? $this->button_text : $this->label;
        ?>
        <div class="customize-control-button">
            <?php if (!empty($this->label)): ?>
                <span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
            <?php endif; ?>
            <?php if (!empty($this->description)): ?>
                <span class="description customize-control-description"><?php echo esc_html($this->description); ?></span>
            <?php endif; ?>
            <button type="button" class="<?php echo esc_attr($button_class); ?>" id="<?php echo esc_attr($this->id); ?>-button"
                <?php foreach ($this->input_attrs as $attr => $value): ?> data-<?php echo esc_attr($attr); ?>="<?php echo esc_attr($value); ?>" <?php endforeach; ?>>
                <?php echo esc_html($button_text); ?>
            </button>
        </div>
        <?php
    }
}
