WordPress – How to create a Widget

How to create a basic Widget?

<?php
/*
 * Plugin Name: Test Widget
 * Version: 0.1
 * Description: This is a Test Widget
 * Author: Me
 * Author URI: http://me.com
 */
?>
<?php
class TestWidget extends WP_Widget
{
    /*********************************************************************
     *    CONSTRUCTOR
     *********************************************************************/
    public function __construct()
    {
        parent::__construct(false, $name = 'This is a Test Widget');    
    } // __construct()
    

    /*********************************************************************
     *    DISPLAYS THE WIDGET
     *********************************************************************/
    function widget($args, $instance)
    {    
        extract($args);

        $html = 'Hey, this is a Test Widget!';

        echo $html;
    } // widget()
    
} // TestWidget

/*********************************************************************
 *    REGISTER THE WIDGET
 *********************************************************************/    
add_action('widgets_init', create_function('', 'return register_widget("TestWidget");'));
?>