<?php
/**
 * Custom Social Widget
 */

class VW_Coaching_Institute_Social_Widget extends WP_Widget {
	
	function __construct() {
		parent::__construct(
			'VW_Coaching_Institute_Social_Widget',
			__('VW Social Icon', 'vw-coaching-institute'),
			array( 'description' => __( 'Widget for Social icons section', 'vw-coaching-institute' ), ) 
		);
	}

	public function widget( $vw_coaching_institute_args, $vw_coaching_institute_instance ) { ?>
		<div class="widget">
			<?php
			$vw_coaching_institute_title = isset( $vw_coaching_institute_instance['title'] ) ? $vw_coaching_institute_instance['title'] : '';
			$vw_coaching_institute_facebook = isset( $vw_coaching_institute_instance['facebook'] ) ? $vw_coaching_institute_instance['facebook'] : '';
			$vw_coaching_institute_twitter = isset( $vw_coaching_institute_instance['twitter'] ) ? $vw_coaching_institute_instance['twitter'] : '';
			$vw_coaching_institute_instagram = isset( $vw_coaching_institute_instance['instagram'] ) ? $vw_coaching_institute_instance['instagram'] : '';
			$vw_coaching_institute_youtube = isset( $vw_coaching_institute_instance['youtube'] ) ? $vw_coaching_institute_instance['youtube'] : '';
			$vw_coaching_institute_dribbal = isset( $vw_coaching_institute_instance['dribbal'] ) ? $vw_coaching_institute_instance['dribbal'] : '';
			$vw_coaching_institute_linkedin = isset( $vw_coaching_institute_instance['linkedin'] ) ? $vw_coaching_institute_instance['linkedin'] : '';
			$vw_coaching_institute_pinterest = isset( $vw_coaching_institute_instance['pinterest'] ) ? $vw_coaching_institute_instance['pinterest'] : '';
			$vw_coaching_institute_tumblr = isset( $vw_coaching_institute_instance['tumblr'] ) ? $vw_coaching_institute_instance['tumblr'] : '';
			

	        echo '<div class="custom-social-icons">';

	        if(!empty($vw_coaching_institute_title) ){ ?><h3 class="custom_title"><?php echo esc_html($vw_coaching_institute_title); ?></h3><?php } ?>
	        <?php if(!empty($vw_coaching_institute_facebook) ){ ?><p class="mb-0"><a class="custom_facebook fff" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_facebook); ?>"><i class="fab fa-facebook-f"></i><span class="screen-reader-text"><?php esc_html_e( 'Facebook','vw-coaching-institute' );?></span></a></p><?php } ?>

	        <?php if(!empty($vw_coaching_institute_twitter) ){ ?><p class="mb-0"><a class="custom_twitter" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_twitter); ?>"><i class="fa-brands fa-x-twitter"></i><span class="screen-reader-text"><?php esc_html_e( 'Twitter','vw-coaching-institute' );?></span></a></p><?php } ?>
	        
	        <?php if(!empty($vw_coaching_institute_instagram) ){ ?><p class="mb-0"><a class="custom_instagram" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_instagram); ?>"><i class="fab fa-instagram"></i><span class="screen-reader-text"><?php esc_html_e( 'Instagram','vw-coaching-institute' );?></span></a></p><?php } ?>

	        <?php if(!empty($vw_coaching_institute_youtube) ){ ?><p class="mb-0"><a class="custom_youtube" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_youtube); ?>"><i class="fab fa-youtube"></i><span class="screen-reader-text"><?php esc_html_e( 'Youtube','vw-coaching-institute' );?></span></a></p><?php } ?>

	        <?php if(!empty($vw_coaching_institute_dribbal) ){ ?><p class="mb-0"><a class="custom_dribbal" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_dribbal); ?>"><i class="fa-solid fa-basketball"></i><span class="screen-reader-text"><?php esc_html_e( 'Dribbal','vw-coaching-institute' );?></span></a></p><?php } ?>

	        <?php if(!empty($vw_coaching_institute_linkedin) ){ ?><p class="mb-0"><a class="custom_linkedin" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_linkedin); ?>"><i class="fab fa-linkedin-in"></i><span class="screen-reader-text"><?php esc_html_e( 'Linkedin','vw-coaching-institute' );?></span></a></p><?php } ?>
	        

	        <?php if(!empty($vw_coaching_institute_pinterest) ){ ?><p class="mb-0"><a class="custom_pinterest" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_pinterest); ?>"><i class="fab fa-pinterest-p"></i><span class="screen-reader-text"><?php esc_html_e( 'Pinterest','vw-coaching-institute' );?></span></a></p><?php } ?>
	        

	        <?php if(!empty($vw_coaching_institute_tumblr) ){ ?><p class="mb-0"><a class="custom_tumblr" target= "_blank" href="<?php echo esc_url($vw_coaching_institute_tumblr); ?>"><i class="fab fa-tumblr"></i><span class="screen-reader-text"><?php esc_html_e( 'Tumblr','vw-coaching-institute' );?></span></a></p><?php } ?>

	        <?php echo '</div>';
			?>
		</div>
		<?php
	}
	
	// Widget Backend 
	public function form( $vw_coaching_institute_instance ) {

		$vw_coaching_institute_title= ''; $vw_coaching_institute_facebook = ''; $vw_coaching_institute_twitter = ''; $vw_coaching_institute_linkedin = '';  $vw_coaching_institute_pinterest = '';$vw_coaching_institute_tumblr = ''; $vw_coaching_institute_instagram = ''; $vw_coaching_institute_youtube = ''; 

		$vw_coaching_institute_title = isset( $vw_coaching_institute_instance['title'] ) ? $vw_coaching_institute_instance['title'] : '';
		$vw_coaching_institute_facebook = isset( $vw_coaching_institute_instance['facebook'] ) ? $vw_coaching_institute_instance['facebook'] : '';
		$vw_coaching_institute_instagram = isset( $vw_coaching_institute_instance['instagram'] ) ? $vw_coaching_institute_instance['instagram'] : '';
		$vw_coaching_institute_twitter = isset( $vw_coaching_institute_instance['twitter'] ) ? $vw_coaching_institute_instance['twitter'] : '';
		$vw_coaching_institute_youtube = isset( $vw_coaching_institute_instance['youtube'] ) ? $vw_coaching_institute_instance['youtube'] : '';
		$vw_coaching_institute_dribbal = isset( $vw_coaching_institute_instance['dribbal'] ) ? $vw_coaching_institute_instance['dribbal'] : '';
		$vw_coaching_institute_linkedin = isset( $vw_coaching_institute_instance['linkedin'] ) ? $vw_coaching_institute_instance['linkedin'] : '';
		$vw_coaching_institute_pinterest = isset( $vw_coaching_institute_instance['pinterest'] ) ? $vw_coaching_institute_instance['pinterest'] : '';
		$vw_coaching_institute_tumblr = isset( $vw_coaching_institute_instance['tumblr'] ) ? $vw_coaching_institute_instance['tumblr'] : '';
		
		?>
		<p>
        <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:','vw-coaching-institute'); ?></label>
        <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_title); ?>">
    	</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('facebook')); ?>"><?php esc_html_e('Facebook:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('facebook')); ?>" name="<?php echo esc_attr($this->get_field_name('facebook')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_facebook); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('twitter')); ?>"><?php esc_html_e('Twitter:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('twitter')); ?>" name="<?php echo esc_attr($this->get_field_name('twitter')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_twitter); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('instagram')); ?>"><?php esc_html_e('Instagram:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('instagram')); ?>" name="<?php echo esc_attr($this->get_field_name('instagram')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_instagram); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('youtube')); ?>"><?php esc_html_e('Youtube:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('youtube')); ?>" name="<?php echo esc_attr($this->get_field_name('youtube')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_youtube); ?>">
		</p>
		<label for="<?php echo esc_attr($this->get_field_id('dribbal')); ?>"><?php esc_html_e('Dribbal:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('dribbal')); ?>" name="<?php echo esc_attr($this->get_field_name('dribbal')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_dribbal); ?>">
		</p>

		<label for="<?php echo esc_attr($this->get_field_id('linkedin')); ?>"><?php esc_html_e('Linkedin:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('linkedin')); ?>" name="<?php echo esc_attr($this->get_field_name('linkedin')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_linkedin); ?>">
		</p>
		<p>
		
		<label for="<?php echo esc_attr($this->get_field_id('pinterest')); ?>"><?php esc_html_e('Pinterest:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('pinterest')); ?>" name="<?php echo esc_attr($this->get_field_name('pinterest')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_pinterest); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('tumblr')); ?>"><?php esc_html_e('Tumblr:','vw-coaching-institute'); ?></label>
		<input class="widefat" id="<?php echo esc_attr($this->get_field_id('tumblr')); ?>" name="<?php echo esc_attr($this->get_field_name('tumblr')); ?>" type="text" value="<?php echo esc_attr($vw_coaching_institute_tumblr); ?>">
		</p>
		<p>
		
		<?php 
	}
	
	public function update( $vw_coaching_institute_new_instance, $vw_coaching_institute_old_instance ) {
		$vw_coaching_institute_instance = array();
		$vw_coaching_institute_instance['title'] = (!empty($vw_coaching_institute_new_instance['title']) ) ? strip_tags($vw_coaching_institute_new_instance['title']) : '';	
        $vw_coaching_institute_instance['facebook'] = (!empty($vw_coaching_institute_new_instance['facebook']) ) ? esc_url_raw($vw_coaching_institute_new_instance['facebook']) : '';
        $vw_coaching_institute_instance['twitter'] = (!empty($vw_coaching_institute_new_instance['twitter']) ) ? esc_url_raw($vw_coaching_institute_new_instance['twitter']) : '';
        $vw_coaching_institute_instance['instagram'] = (!empty($vw_coaching_institute_new_instance['instagram']) ) ? esc_url_raw($vw_coaching_institute_new_instance['instagram']) : '';
        $vw_coaching_institute_instance['youtube'] = (!empty($vw_coaching_institute_new_instance['youtube']) ) ? esc_url_raw($vw_coaching_institute_new_instance['youtube']) : '';
        $vw_coaching_institute_instance['dribbal'] = (!empty($vw_coaching_institute_new_instance['dribbal']) ) ? esc_url_raw($vw_coaching_institute_new_instance['dribbal']) : '';
        $vw_coaching_institute_instance['linkedin'] = (!empty($vw_coaching_institute_new_instance['linkedin']) ) ? esc_url_raw($vw_coaching_institute_new_instance['linkedin']) : '';
        $vw_coaching_institute_instance['pinterest'] = (!empty($vw_coaching_institute_new_instance['pinterest']) ) ? esc_url_raw($vw_coaching_institute_new_instance['pinterest']) : '';
        $vw_coaching_institute_instance['tumblr'] = (!empty($vw_coaching_institute_new_instance['tumblr']) ) ? esc_url_raw($vw_coaching_institute_new_instance['tumblr']) : '';
     	
     	
		return $vw_coaching_institute_instance;
	}
}

function vw_coaching_institute_custom_load_widget() {
	register_widget( 'VW_Coaching_Institute_Social_Widget' );
}
add_action( 'widgets_init', 'vw_coaching_institute_custom_load_widget' );