<?php
/**
 * RT Magazine Theme Customizer Control
 *
 * @package RT_Magazine
 */


//  Customizer Control
if (class_exists('WP_Customize_Control') && ! class_exists( 'Rt_Magazine_Image_Radio_Control' ) ) {
    /**
    * Customize sidebar layout control.
    */
    class Rt_Magazine_Image_Radio_Control extends WP_Customize_Control {

        public function render_content() {

            if (empty($this->choices))
                return;

            $name = '_customize-radio-' . $this->id;
            ?>
            <span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
            <ul class="controls" id='rt-magazine-img-container'>
                <?php
                foreach ($this->choices as $value => $label) :
                    $class = ($this->value() == $value) ? 'rt-magazine-radio-img-selected rt-magazine-radio-img-img' : 'rt-magazine-radio-img-img';
                    ?>
                    <li style="display: inline;">
                        <label>
                            <input <?php $this->link(); ?>style = 'display:none' type="radio" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name); ?>" <?php
                                                          $this->link();
                                                          checked($this->value(), $value);
                                                          ?> />
                            <img src='<?php echo esc_url($label); ?>' class='<?php echo esc_attr($class); ?>' />
                        </label>
                    </li>
                    <?php
                endforeach;
                ?>
            </ul>
            <?php
        }

    }
}
