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

function serpentsoft_search_widget_init() {
    register_widget('serpentsoft_search_widget');
}

class serpentsoft_search_widget extends WP_Widget {

    function serpentsoft_search_widget() {
        $widget_ops = array('classname' => 'search-section w-search');
        $control_ops = array('width' => 250, 'height' => 350, 'id_base' => 'id-widget-search');
        $this->WP_Widget('id-widget-search', theme_name . ' - Search', $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; ?>

        <form method="get" action="<?php echo home_url(); ?>/" class="form-search clearfix search-box">
            <div class="input-append input-block-level">
                <input id="s" name="s" type="search" class="span10 search-query" placeholder="<?php _e('Type and Press Enter', 'serpentsoft') ?>" required />

                <button id="searchsubmit" type="submit" class="btn"><i class="icon-search"></i></button>
            </div>
        </form>

        <?php
        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' => __('Search', '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
    }
}
?>