<?php

class TS_ALASKA_Follow_us extends WP_Widget
{

    function TS_ALASKA_Follow_us()
    {

        $widget_ops = array( 'classname' => 'TS_ALASKA_Follow_us', 'description' => 'The Follow us social' );

        parent::__construct( 'TS_ALASKA_Follow_us', THEMESTUDIO_THEME_NAME . ' Follow_us ', $widget_ops );

    }


    function widget( $args, $instance )
    {

        extract( $args, EXTR_SKIP );
        echo $before_widget;
        $title = empty( $instance[ 'title' ] ) ? 'Follow us' : apply_filters( 'widget_title', $instance[ 'title' ] );
        $URL_twitter = empty( $instance[ 'twitter' ] ) ? '' : $instance[ 'twitter' ];
        $URL_tumblr = empty( $instance[ 'tumblr' ] ) ? '' : $instance[ 'tumblr' ];
        $URL_youtube = empty( $instance[ 'youtube' ] ) ? '' : $instance[ 'youtube' ];
        $URL_vine = empty( $instance[ 'vine' ] ) ? '' : $instance[ 'vine' ];
        $URL_facebook = empty( $instance[ 'facebook' ] ) ? '' : $instance[ 'facebook' ];
        $URL_google = empty( $instance[ 'google' ] ) ? '' : $instance[ 'google' ];
        $URL_behance = empty( $instance[ 'behance' ] ) ? '' : $instance[ 'behance' ];
        $URL_dribbble = empty( $instance[ 'dribbble' ] ) ? '' : $instance[ 'dribbble' ];
        $URL_linkedin = empty( $instance[ 'linkedin' ] ) ? '' : $instance[ 'linkedin' ];
        $URL_instagram = empty( $instance[ 'instagram' ] ) ? '' : $instance[ 'instagram' ];
        $URL_pinterest = empty( $instance[ 'pinterest' ] ) ? '' : $instance[ 'pinterest' ];
        $URL_skype = empty( $instance[ 'skype' ] ) ? '' : $instance[ 'skype' ];
        $URL_flickr = empty( $instance[ 'flickr' ] ) ? '' : $instance[ 'flickr' ];
        $URL_soundcloud = empty( $instance[ 'soundcloud' ] ) ? '' : $instance[ 'soundcloud' ];
        $URL_reddit = empty( $instance[ 'reddit' ] ) ? '' : $instance[ 'reddit' ];
        $URL_xing = empty( $instance[ 'xing' ] ) ? '' : $instance[ 'xing' ];
        $URL_snapchat = empty( $instance[ 'snapchat' ] ) ? '' : $instance[ 'snapchat' ];
        $URL_slideshare = empty( $instance[ 'slideshare' ] ) ? '' : $instance[ 'slideshare' ];
        $URL_github = empty( $instance[ 'github' ] ) ? '' : $instance[ 'github' ];

        
        echo '<div class="ts-social-footer widget">						
						<h3>' . $title . '</h3>';
        if ( trim( $URL_twitter ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_twitter ) . '" target="__blank"><span><i class="fa fa-twitter"></i></span></a>';
        }
        if ( trim( $URL_facebook ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_facebook ) . '" target="__blank"><span><i class="fa fa-facebook"></i></span></a>';
        }
        if ( trim( $URL_google ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_google ) . '" target="__blank"><span><i class="fa fa-google-plus"></i></span></a>';
        }
        if ( trim( $URL_youtube ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_youtube ) . '" target="__blank"><span><i class="fa fa-youtube"></i></span></a>';
        }
        if ( trim( $URL_vine ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_vine ) . '" target="__blank"><span><i class="fa fa-vine"></i></span></a>	';
        }
        if ( trim( $URL_behance ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_behance ) . '" target="__blank"><span><i class="fa fa-behance"></i></span></a>';
        }
        if ( trim( $URL_dribbble ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_dribbble ) . '" target="__blank"><span><i class="fa fa-dribbble"></i></span></a>';
        }
        if ( trim( $URL_tumblr ) != '' ) {
            echo '		<a href="' . esc_URL( $URL_tumblr ) . '" target="__blank"><span><i class="fa fa-tumblr"></i></span></a>';
        }
        if ( trim( $URL_linkedin ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_linkedin ) . '" target="__blank"><span><i class="fa fa-linkedin"></i></span></a>';
        }
        if ( trim( $URL_instagram ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_instagram ) . '" target="__blank"><span><i class="fa fa-instagram"></i></span></a>';
        }
        if ( trim( $URL_pinterest ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_pinterest ) . '" target="__blank"><span><i class="fa fa-pinterest"></i></span></a>';
        }
        if ( trim( $URL_skype ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_skype ) . '" target="__blank"><span><i class="fa fa-skype"></i></span></a>';
        }
        if ( trim( $URL_flickr ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_flickr ) . '" target="__blank"><span><i class="fa fa-flickr"></i></span></a>';
        }
        if ( trim( $URL_soundcloud ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_soundcloud ) . '" target="__blank"><span><i class="fa fa-soundcloud"></i></span></a>';
        }
        if ( trim( $URL_reddit ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_reddit ) . '" target="__blank"><span><i class="fa fa-reddit"></i></span></a>';
        }
        if ( trim( $URL_whatsapp ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_whatsapp ) . '" target="__blank"><span><i class="fa fa-whatsapp"></i></span></a>';
        }
        if ( trim( $URL_xing ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_xing ) . '" target="__blank"><span><i class="fa fa-xing"></i></span></a>';
        }
        if ( trim( $URL_snapchat ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_snapchat ) . '" target="__blank"><span><i class="fa fa-snapchat"></i></span></a>';
        }
        if ( trim( $URL_slideshare ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_slideshare ) . '" target="__blank"><span><i class="fa fa-slideshare"></i></span></a>';
        }
        if ( trim( $URL_github ) != '' ) {
            echo '    <a href="' . esc_URL( $URL_github ) . '" target="__blank"><span><i class="fa fa-github"></i></span></a>';
        }
        
        echo '	</div>
					<!-- social_footer -->';

        echo $after_widget;

    }


    function update( $new_instance, $old_instance )
    {

        $instance = $old_instance;

        $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
        $instance[ 'twitter' ] = strip_tags( $new_instance[ 'twitter' ] );
        $instance[ 'tumblr' ] = strip_tags( $new_instance[ 'tumblr' ] );
        $instance[ 'youtube' ] = strip_tags( $new_instance[ 'youtube' ] );
        $instance[ 'vine' ] = strip_tags( $new_instance[ 'vine' ] );
        $instance[ 'facebook' ] = strip_tags( $new_instance[ 'facebook' ] );
        $instance[ 'google' ] = strip_tags( $new_instance[ 'google' ] );
        $instance[ 'behance' ] = strip_tags( $new_instance[ 'behance' ] );
        $instance[ 'dribbble' ] = strip_tags( $new_instance[ 'dribbble' ] );
        $instance[ 'linkedin' ] = strip_tags( $new_instance[ 'linkedin' ] );
        $instance[ 'instagram' ] = strip_tags( $new_instance[ 'instagram' ] );
        $instance[ 'pinterest' ] = strip_tags( $new_instance[ 'pinterest' ] );
        $instance[ 'skype' ] = strip_tags( $new_instance[ 'skype' ] );
        $instance[ 'flickr' ] = strip_tags( $new_instance[ 'flickr' ] );
        $instance[ 'soundcloud' ] = strip_tags( $new_instance[ 'soundcloud' ] );
        $instance[ 'reddit' ] = strip_tags( $new_instance[ 'reddit' ] );
        $instance[ 'whatsapp' ] = strip_tags( $new_instance[ 'whatsapp' ] );
        $instance[ 'xing' ] = strip_tags( $new_instance[ 'xing' ] );
        $instance[ 'snapchat' ] = strip_tags( $new_instance[ 'snapchat' ] );
        $instance[ 'slideshare' ] = strip_tags( $new_instance[ 'slideshare' ] );
        $instance[ 'github' ] = strip_tags( $new_instance[ 'github' ] );
       
       
        return $instance;

    }


    function form( $instance )
    {

        $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'twitter' => '', 'tumblr' => '', 'youtube' => '', 'vine' => '', 'facebook' => '', 'google' => '', 'behance' => '', 'dribbble' => '','linkedin' =>'','instagram' => '','pinterest' => '','skype' => '','flickr' => '','soundcloud' => '','reddit' => '','whatsapp' => '','xing' => '','snapchat' => '','slideshare' => '','github' => '' ) );

        $title = strip_tags( $instance[ 'title' ] );
        $twitter = strip_tags( $instance[ 'twitter' ] );
        $tumblr = strip_tags( $instance[ 'tumblr' ] );
        $youtube = strip_tags( $instance[ 'youtube' ] );
        $vine = strip_tags( $instance[ 'vine' ] );
        $facebook = strip_tags( $instance[ 'facebook' ] );
        $google = strip_tags( $instance[ 'google' ] );
        $behance = strip_tags( $instance[ 'behance' ] );
        $dribbble = strip_tags( $instance[ 'dribbble' ] );
        $linkedin = strip_tags( $instance[ 'linkedin' ] );
        $instagram = strip_tags( $instance[ 'instagram' ] );
        $pinterest = strip_tags( $instance[ 'pinterest' ] );
        $skype = strip_tags( $instance[ 'skype' ] );
        $flickr = strip_tags( $instance[ 'flickr' ] );
        $soundcloud = strip_tags( $instance[ 'soundcloud' ] );
        $reddit = strip_tags( $instance[ 'reddit' ] );
        $whatsapp = strip_tags( $instance[ 'whatsapp' ] );
        $xing = strip_tags( $instance[ 'xing' ] );
        $snapchat = strip_tags( $instance[ 'snapchat' ] );
        $slideshare = strip_tags( $instance[ 'slideshare' ] );
        $github = strip_tags( $instance[ 'github' ] );
        

        ?>

        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>">Title (default "Follow us"): <input
                    class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
                    name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
                    value="<?php echo esc_attr( $title ); ?>"/></label></p>
        <p><label for="<?php echo $this->get_field_id( 'twitter' ); ?>">URL Twitter : <input class="widefat"
                                                                                             id="<?php echo $this->get_field_id( 'twitter' ); ?>"
                                                                                             name="<?php echo $this->get_field_name( 'twitter' ); ?>"
                                                                                             type="text"
                                                                                             value="<?php echo esc_attr( $twitter ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'facebook' ); ?>">URL Facebook : <input class="widefat"
                                                                                               id="<?php echo $this->get_field_id( 'facebook' ); ?>"
                                                                                               name="<?php echo $this->get_field_name( 'facebook' ); ?>"
                                                                                               type="text"
                                                                                               value="<?php echo esc_attr( $facebook ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'google' ); ?>">URL Google plus : <input class="widefat"
                                                                                                id="<?php echo $this->get_field_id( 'google' ); ?>"
                                                                                                name="<?php echo $this->get_field_name( 'google' ); ?>"
                                                                                                type="text"
                                                                                                value="<?php echo esc_attr( $google ); ?>" /></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'youtube' ); ?>">URL Youtube : <input class="widefat"
                                                                                             id="<?php echo $this->get_field_id( 'youtube' ); ?>"
                                                                                             name="<?php echo $this->get_field_name( 'youtube' ); ?>"
                                                                                             type="text"
                                                                                             value="<?php echo esc_attr( $youtube ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'vine' ); ?>">URL Vine: <input class="widefat"
                                                                                      id="<?php echo $this->get_field_id( 'vine' ); ?>"
                                                                                      name="<?php echo $this->get_field_name( 'vine' ); ?>"
                                                                                      type="text"
                                                                                      value="<?php echo esc_attr( $vine ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'behance' ); ?>">URL Behance : <input class="widefat"
                                                                                             id="<?php echo $this->get_field_id( 'behance' ); ?>"
                                                                                             name="<?php echo $this->get_field_name( 'behance' ); ?>"
                                                                                             type="text"
                                                                                             value="<?php echo esc_attr( $behance ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'dribbble' ); ?>">URL Dribbble : <input class="widefat"
                                                                                               id="<?php echo $this->get_field_id( 'dribbble' ); ?>"
                                                                                               name="<?php echo $this->get_field_name( 'dribbble' ); ?>"
                                                                                               type="text"
                                                                                               value="<?php echo esc_attr( $dribbble ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'tumblr' ); ?>">URL Tumblr: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'tumblr' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'tumblr' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $tumblr ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'linkedin' ); ?>">URL Linkedin: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'linkedin' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'linkedin' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $linkedin ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'instagram' ); ?>">URL Instagram: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'instagram' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'instagram' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $instagram ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'pinterest' ); ?>">URL Pinterest: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'pinterest' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'pinterest' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $pinterest ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'skype' ); ?>">URL Skype: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'skype' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'skype' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $skype ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'flickr' ); ?>">URL Flickr: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'flickr' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'flickr' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $flickr ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'soundcloud' ); ?>">URL Soundcloud: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'soundcloud' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'soundcloud' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $soundcloud ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'reddit' ); ?>">URL Reddit: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'reddit' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'reddit' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $reddit ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'whatsapp' ); ?>">URL Whatsapp: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'whatsapp' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'whatsapp' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $whatsapp ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'xing' ); ?>">URL Xing: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'xing' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'xing' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $xing ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'snapchat' ); ?>">URL Snapchat: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'snapchat' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'snapchat' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $snapchat ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'slideshare' ); ?>">URL Slideshare: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'slideshare' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'slideshare' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $slideshare ); ?>"/></label>
        </p>
        <p><label for="<?php echo $this->get_field_id( 'github' ); ?>">URL Github: <input class="widefat"
                                                                                          id="<?php echo $this->get_field_id( 'github' ); ?>"
                                                                                          name="<?php echo $this->get_field_name( 'github' ); ?>"
                                                                                          type="text"
                                                                                          value="<?php echo esc_attr( $github ); ?>"/></label>
        </p>
       
        <?php

    }

}

function themestudio_Follow_us_widget()
{
    register_widget( 'TS_ALASKA_Follow_us' );
}

add_action( 'widgets_init', 'themestudio_Follow_us_widget' );