<?php
/**
 * VW Tour Lite Customizer Custom Controls
 *
 */

if ( class_exists( 'WP_Customize_Control' ) ) {

	class VW_Tour_Lite_Toggle_Switch_Custom_Control extends WP_Customize_Control {
		public $type = 'toogle_switch';
		public function enqueue(){
			wp_enqueue_style( 'vw_tour_lite_custom_controls_css', trailingslashit( esc_url(get_template_directory_uri()) ) . 'css/customizer.css', array(), '1.0', 'all' );
		}
		public function render_content(){
		?>
			<div class="toggle-switch-control">
				<div class="toggle-switch">
					<input type="checkbox" id="<?php echo esc_attr($this->id); ?>" name="<?php echo esc_attr($this->id); ?>" class="toggle-switch-checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); checked( $this->value() ); ?>>
					<label class="toggle-switch-label" for="<?php echo esc_attr( $this->id ); ?>">
						<span class="toggle-switch-inner"></span>
						<span class="toggle-switch-switch"></span>
					</label>
				</div>
				<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
				<?php if( !empty( $this->description ) ) { ?>
					<span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
				<?php } ?>
			</div>
		<?php
		}
	}

	class VW_Tour_Lite_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='vw-tour-lite-img-container'>
	           <?php
	           foreach ($this->choices as $value => $label) :
	               $class = ($this->value() == $value) ? 'vw-tour-lite-radio-img-selected vw-tour-lite-radio-img-img' : 'vw-tour-lite-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
	   } 
	}

	if ( ! function_exists( 'vw_tour_lite_switch_sanitization' ) ) {
		function vw_tour_lite_switch_sanitization( $input ) {
			if ( true === $input ) {
				return 1;
			} else {
				return 0;
			}
		}
	}

}