widget is display in WP admin panel but data not saving

anybody who help me to resolve this issue
Kind ragard

//add_action( 'widgets_init', create_function( '', 'register_widget("Team");' ) );

class Team extends WP_Widget
{
    /**
     * Constructor
     **/
    function __construct() {
        // Add Widget scripts
        add_action('admin_enqueue_scripts', array($this, 'scripts'));
        parent::__construct(
            'TeamData1', // Base ID
            __( 'Team data Form', 'TeamData' ), // Name
            array( 'description' => __( 'Our Widgetfor Team data on page', 'TeamData' ), ) // Args
        );
    }
    /**
     * Upload the Javascripts for the media uploader
     */
    public function scripts()
    {
        wp_enqueue_script( 'media-upload' );
        wp_enqueue_media();
        wp_enqueue_script('our_admin', get_template_directory_uri() . '/assets/js/our_admin.js', array('jquery'));
    }

    /**
     * Add the styles for the upload media box
     */
    public function upload_styles()
    {
        wp_enqueue_style('thickbox');
    }
    public function widget( $args, $instance ) {

?>
       <div class="column-team w-col w-col-4 w-col-stack">
            <div class="team-image">
<?php
        $TeamImage = ! empty( $instance['TeamImage'] ) ? $instance['TeamImage'] : '';
        ob_start();
        if($TeamImage):
?>
       <img src="<?php echo esc_url($TeamImage); ?>">
        <?php endif; ?>
        <div class="team-desktop">


<?php

        $name           = apply_filters( 'widget_title', empty( $instance['name'] )         ? __( 'Default title', 'TeamData' ) : $instance['name'] );
        $designation    = apply_filters( 'widget_title', empty( $instance['designation'] )  ? __( 'Default title', 'TeamData' ) : $instance['designation'] );
        $FbUrl          = apply_filters( 'widget_title', empty( $instance['FbUrl'] )        ? __( 'Default title', 'TeamData' ) : $instance['FbUrl'] );
        $LinkedinUrl    = apply_filters( 'widget_title', empty( $instance['LinkedinUrl'] )  ? __( 'Default title', 'TeamData' ) : $instance['LinkedinUrl'] );
        $TwitterUrl     = apply_filters( 'widget_title', empty( $instance['TwitterUrl'] )   ? __( 'Default title', 'TeamData' ) : $instance['TwitterUrl'] );

        //echo $args['before_widget'];
        if ( ! empty( $instance['name'] ) ) {

            echo "<h4 class='team'>".$name."</h4>";
        }
        if ( ! empty( $instance['designation'] ) ) {
            echo '<div class="in-contact sub-text">'.$designation.'</div>';
        }
        ?>
        <div class="social-block">
            <a class="social-icon w-inline-block" href="<?php echo $FbUrl; ?>"><img src="<?php echo get_bloginfo('template_url') ?>/assets/image/facebook_footer.svg" width="16"></a>
            <a class="social-icon w-inline-block" href="<?php echo $LinkedinUrl; ?>"><img src="<?php echo get_bloginfo('template_url') ?>/assets/image/linkedin_footer.svg" width="16"></a>
            <a class="social-icon w-inline-block" href="<?php echo $TwitterUrl; ?>"><img src="<?php echo get_bloginfo('template_url') ?>/assets/image/twitter_footer.svg" width="16"></a>
        </div>></div></div></div>
<?php  

        //echo $args['after_widget'];
        //ob_end_flush();
    }


    public function form( $instance ) {
        $name =         ! empty( $instance['name'] )        ? $instance['name'] : __( 'New name', 'TeamData' );
        $designation  = ! empty( $instance['designation'] ) ? $instance['designation'] : __( 'New designation', 'TeamData' );
        $FbUrl =        ! empty( $instance['FbUrl'] )       ? $instance['FbUrl'] : __( 'https://www.facebook.com/', 'TeamData' );
        $LinkedinUrl =  ! empty( $instance['LinkedinUrl'] ) ? $instance['LinkedinUrl'] : __( 'https://www.linkedin.com/', 'TeamData' );
        $TwitterUrl =   ! empty( $instance['TwitterUrl'] )  ? $instance['TwitterUrl'] : __( 'https://www.twitter.com/', 'TeamData' );
        $TeamImage =    ! empty( $instance['TeamImage'] )   ? $instance['TeamImage'] : '';
?>
       <p>
            <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e( 'name:' ); ?></label>
            <input class="widefat" maxlength="20" id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" type="text" value="<?php echo esc_attr( $name ); ?>">
        </p>
        <p>
            <label for="<?php echo $this->get_field_id( 'designation' ); ?>"><?php _e( 'designation:' ); ?></label>
            <input class="widefat" maxlength="20" id="<?php echo $this->get_field_id( 'designation' ); ?>" name="<?php echo $this->get_field_name( 'designation' ); ?>" type="text" value="<?php echo esc_attr( $designation ); ?>">
        </p>
        <p>
            <label for="<?php echo $this->get_field_id( 'FbUrl' ); ?>"><?php _e( 'FbUrl:' ); ?></label>
            <input class="widefat" maxlength="150" id="<?php echo $this->get_field_id( 'FbUrl' ); ?>" name="<?php echo $this->get_field_name( 'FbUrl' ); ?>" type="text" value="<?php echo esc_attr( $FbUrl ); ?>">
        </p>
        <p>
            <label for="<?php echo $this->get_field_id( 'LinkedinUrl' ); ?>"><?php _e( 'LinkedinUrl:' ); ?></label>
            <input class="widefat" maxlength="150" id="<?php echo $this->get_field_id( 'LinkedinUrl' ); ?>" name="<?php echo $this->get_field_name( 'LinkedinUrl' ); ?>" type="text" value="<?php echo esc_attr( $LinkedinUrl ); ?>">
        </p>
        <p>
            <label for="<?php echo $this->get_field_id( 'TwitterUrl' ); ?>"><?php _e( 'TwitterUrl:' ); ?></label>
            <input class="widefat" maxlength="150" id="<?php echo $this->get_field_id( 'TwitterUrl' ); ?>" name="<?php echo $this->get_field_name( 'TwitterUrl' ); ?>" type="text" value="<?php echo esc_attr( $TwitterUrl ); ?>">
        </p>

        <p>
            <label for="<?php echo $this->get_field_id( 'TeamImage' ); ?>"><?php _e( 'UserImage:' ); ?></label>
            <input class="widefat" id="<?php echo $this->get_field_id( 'TeamImage' ); ?>" name="<?php echo $this->get_field_name( 'TeamImage' ); ?>" type="text" value="<?php echo esc_url( $TeamImage ); ?>" />
            <button class="upload_image_button button button-primary">Upload Image</button>
        </p>
<?php
    }
    public function update( $new_instance, $old_instance ) {
        $instance = array();
        $instance['name']           = ( ! empty( $new_instance['name'] ) ) ? strip_tags( $new_instance['name'] ) : '';
        $instance['designation']    = ( ! empty( $new_instance['designation'] ) )  ? strip_tags( $new_instance['designation'] )  : '';
        $instance['FbUrl']          = ( ! empty( $new_instance['FbUrl'] ) ) ? strip_tags( $new_instance['FbUrl'] ) : '';
        $instance['LinkedinUrl']    = ( ! empty( $new_instance['LinkedinUrl'] ) ) ? strip_tags( $new_instance['LinkedinUrl'] ) : '';
        $instance['TwitterUrl']     = ( ! empty( $new_instance['TwitterUrl'] ) ) ? strip_tags( $new_instance['TwitterUrl'] ) : '';
        $instance['TeamImage']      = ( ! empty( $new_instance['TeamImage'] ) ) ? $new_instance['TeamImage'] : '';
        return $instance;
    }
}
function register_Team_widget() {
    register_widget( 'Team' );
    register_sidebar( array(
        'name' => __( 'This is for Display Team Data', 'theme-slug' ),
        'id' => 'TeamFrom',
        'description' => __( 'Widgets in this area will be shown on Main homepage.', 'theme-slug' ),
        //'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'before_widget' => '',
        'after_widget'  => '',
        'before_text_1'  => '',
        'after_text_1'   => '',
    ) );
}
add_action( 'widgets_init', 'register_Team_widget' );
?>

Read more here: widget is display in WP admin panel but data not saving

Leave a Reply

Your email address will not be published. Required fields are marked *