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

class Immigration_Consulting_Social_Widget extends WP_Widget {
	
	function __construct() {
		parent::__construct(
			'Immigration_Consulting_Social_Widget',
			__('VW Social Icon', 'immigration-consulting'),
			array( 'description' => __( 'Widget for Social icons section', 'immigration-consulting' ), ) 
		);
	}

	public function widget( $immigration_consulting_args, $immigration_consulting_instance ) { ?>
		<div class="widget">
			<?php
			$immigration_consulting_title = isset( $immigration_consulting_instance['title'] ) ? $immigration_consulting_instance['title'] : '';
			$immigration_consulting_facebook = isset( $immigration_consulting_instance['facebook'] ) ? $immigration_consulting_instance['facebook'] : '';
			$immigration_consulting_twitter = isset( $immigration_consulting_instance['twitter'] ) ? $immigration_consulting_instance['twitter'] : '';
			$immigration_consulting_instagram = isset( $immigration_consulting_instance['instagram'] ) ? $immigration_consulting_instance['instagram'] : '';
			$immigration_consulting_youtube = isset( $immigration_consulting_instance['youtube'] ) ? $immigration_consulting_instance['youtube'] : '';
			$immigration_consulting_dribbal = isset( $immigration_consulting_instance['dribbal'] ) ? $immigration_consulting_instance['dribbal'] : '';
			$immigration_consulting_linkedin = isset( $immigration_consulting_instance['linkedin'] ) ? $immigration_consulting_instance['linkedin'] : '';
			$immigration_consulting_pinterest = isset( $immigration_consulting_instance['pinterest'] ) ? $immigration_consulting_instance['pinterest'] : '';
			$immigration_consulting_tumblr = isset( $immigration_consulting_instance['tumblr'] ) ? $immigration_consulting_instance['tumblr'] : '';
			

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

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

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

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

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

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

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

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

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

		$immigration_consulting_title= ''; $immigration_consulting_facebook = ''; $immigration_consulting_twitter = ''; $immigration_consulting_linkedin = '';  $immigration_consulting_pinterest = '';$immigration_consulting_tumblr = ''; $immigration_consulting_instagram = ''; $immigration_consulting_youtube = ''; 

		$immigration_consulting_title = isset( $immigration_consulting_instance['title'] ) ? $immigration_consulting_instance['title'] : '';
		$immigration_consulting_facebook = isset( $immigration_consulting_instance['facebook'] ) ? $immigration_consulting_instance['facebook'] : '';
		$immigration_consulting_instagram = isset( $immigration_consulting_instance['instagram'] ) ? $immigration_consulting_instance['instagram'] : '';
		$immigration_consulting_twitter = isset( $immigration_consulting_instance['twitter'] ) ? $immigration_consulting_instance['twitter'] : '';
		$immigration_consulting_youtube = isset( $immigration_consulting_instance['youtube'] ) ? $immigration_consulting_instance['youtube'] : '';
		$immigration_consulting_dribbal = isset( $immigration_consulting_instance['dribbal'] ) ? $immigration_consulting_instance['dribbal'] : '';
		$immigration_consulting_linkedin = isset( $immigration_consulting_instance['linkedin'] ) ? $immigration_consulting_instance['linkedin'] : '';
		$immigration_consulting_pinterest = isset( $immigration_consulting_instance['pinterest'] ) ? $immigration_consulting_instance['pinterest'] : '';
		$immigration_consulting_tumblr = isset( $immigration_consulting_instance['tumblr'] ) ? $immigration_consulting_instance['tumblr'] : '';
		
		?>
		<p>
        <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:','immigration-consulting'); ?></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($immigration_consulting_title); ?>">
    	</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('facebook')); ?>"><?php esc_html_e('Facebook:','immigration-consulting'); ?></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($immigration_consulting_facebook); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('twitter')); ?>"><?php esc_html_e('Twitter:','immigration-consulting'); ?></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($immigration_consulting_twitter); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('instagram')); ?>"><?php esc_html_e('Instagram:','immigration-consulting'); ?></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($immigration_consulting_instagram); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('youtube')); ?>"><?php esc_html_e('Youtube:','immigration-consulting'); ?></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($immigration_consulting_youtube); ?>">
		</p>
		<label for="<?php echo esc_attr($this->get_field_id('dribbal')); ?>"><?php esc_html_e('Dribbal:','immigration-consulting'); ?></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($immigration_consulting_dribbal); ?>">
		</p>

		<label for="<?php echo esc_attr($this->get_field_id('linkedin')); ?>"><?php esc_html_e('Linkedin:','immigration-consulting'); ?></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($immigration_consulting_linkedin); ?>">
		</p>
		<p>
		
		<label for="<?php echo esc_attr($this->get_field_id('pinterest')); ?>"><?php esc_html_e('Pinterest:','immigration-consulting'); ?></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($immigration_consulting_pinterest); ?>">
		</p>
		<p>
		<label for="<?php echo esc_attr($this->get_field_id('tumblr')); ?>"><?php esc_html_e('Tumblr:','immigration-consulting'); ?></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($immigration_consulting_tumblr); ?>">
		</p>
		<p>
		
		<?php 
	}
	
	public function update( $immigration_consulting_new_instance, $immigration_consulting_old_instance ) {
		$immigration_consulting_instance = array();
		$immigration_consulting_instance['title'] = (!empty($immigration_consulting_new_instance['title']) ) ? strip_tags($immigration_consulting_new_instance['title']) : '';	
        $immigration_consulting_instance['facebook'] = (!empty($immigration_consulting_new_instance['facebook']) ) ? esc_url_raw($immigration_consulting_new_instance['facebook']) : '';
        $immigration_consulting_instance['twitter'] = (!empty($immigration_consulting_new_instance['twitter']) ) ? esc_url_raw($immigration_consulting_new_instance['twitter']) : '';
        $immigration_consulting_instance['instagram'] = (!empty($immigration_consulting_new_instance['instagram']) ) ? esc_url_raw($immigration_consulting_new_instance['instagram']) : '';
        $immigration_consulting_instance['youtube'] = (!empty($immigration_consulting_new_instance['youtube']) ) ? esc_url_raw($immigration_consulting_new_instance['youtube']) : '';
        $immigration_consulting_instance['dribbal'] = (!empty($immigration_consulting_new_instance['dribbal']) ) ? esc_url_raw($immigration_consulting_new_instance['dribbal']) : '';
        $immigration_consulting_instance['linkedin'] = (!empty($immigration_consulting_new_instance['linkedin']) ) ? esc_url_raw($immigration_consulting_new_instance['linkedin']) : '';
        $immigration_consulting_instance['pinterest'] = (!empty($immigration_consulting_new_instance['pinterest']) ) ? esc_url_raw($immigration_consulting_new_instance['pinterest']) : '';
        $immigration_consulting_instance['tumblr'] = (!empty($immigration_consulting_new_instance['tumblr']) ) ? esc_url_raw($immigration_consulting_new_instance['tumblr']) : '';
     	
     	
		return $immigration_consulting_instance;
	}
}

function immigration_consulting_custom_load_widget() {
	register_widget( 'Immigration_Consulting_Social_Widget' );
}
add_action( 'widgets_init', 'immigration_consulting_custom_load_widget' );