<?php
add_action('widgets_init', 'serpentsoft_login_widget_init');

function serpentsoft_login_widget_init() {
    register_widget('serpentsoft_login_widget');
}

class serpentsoft_login_widget extends WP_Widget {

    function serpentsoft_login_widget() {
        $widget_ops = array('classname' => 'login-section w-login');
        $control_ops = array('width' => 250, 'height' => 350, 'id_base' => 'id-widget-login');
        $this->WP_Widget('id-widget-login', theme_name . ' - Login', $widget_ops, $control_ops);
    }

    function widget($args, $instance) {
        extract($args);

        $title = apply_filters('widget_title', $instance['widget_title']);

        echo $before_widget;
        if ($title) :
            echo $before_title;
            echo $title;
            echo $after_title;
        endif;

        wp_reset_query();
        
        serpentsoft_create_login();
        
        echo $after_widget;
    }

    function update($new_instance, $old_instance) {
        $instance = $old_instance;
        $instance['widget_title'] = strip_tags($new_instance['widget_title']);
        return $instance;
    }

    function form($instance) {
        $defaults = array('widget_title' => __('Login', 'serpentsoft'));
        $instance = wp_parse_args((array) $instance, $defaults);
        ?>

        <p>
            <label for="<?php echo $this->get_field_id('widget_title'); ?>"><?php _e('Title', 'serpentsoft'); ?></label>

            <input id="<?php echo $this->get_field_id('widget_title'); ?>" name="<?php echo $this->get_field_name('widget_title'); ?>" value="<?php echo $instance['widget_title']; ?>" type="text" />
        </p>
        
<?php } } ?>