<?php

class Irontec_Online_Users_Widget extends WP_Widget {
    
    /**
     * constructor
     */
    function Irontec_Online_Users_Widget() {
        $widget_ops = array( 'description' => 'Online Users' );
        parent::WP_Widget(false, $name = 'Online Users', $widget_ops);
    }
    
    /**
     * @see WP_Widget::widget
    */
    function widget($args, $instance) {
        
        global $wpdb, $bp;
        
        extract( $args );
        
        echo $before_widget;
        /**
         * change the title
         */
        $title = apply_filters('widget_title', $instance['title']);
        
        if ( $title ) {
            $before_title = str_replace ('widgettitle','widgettitle new-users', $before_title);
            echo $before_title;
            echo __( 'Qui&eacute;n est&aacute; en l&iacute;nea', 'buddypress' );
            echo $after_title;
        }
        
        require_once(dirname(__FILE__) . '/widget.php');
        
        echo $after_widget;
    }
    
    /**
     * @see WP_Widget::update
     */
    function update($new_instance, $old_instance) {
        
        $instance = $old_instance;
        $instance['title'] = strip_tags($new_instance['title']);
        
        return $instance;
    }
    
    /**
     * @see WP_Widget::form
     */
    function form($instance) {
        
        global $wpdb;
        
        $title = esc_attr($instance['title']);
        ?>
        <p>
            <label for="<?php echo $this->get_field_id('title'); ?>">
                <?php _e('Title:'); ?>
            </label>
            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php if ($title) echo $title; else echo " "; ?>" />
        </p>
    <?php
    
    }
}

add_action('widgets_init', create_function('', 'return register_widget("Irontec_Online_Users_Widget");'));
?>