You really need to be using the Widget API.
Here is a widget shell to get you started.
class WPSE_Widget_Shell extends WP_Widget {
function __construct() {
$opts = array(
'description' => 'Brief description; shows on the backend'
);
parent::WP_Widget(
'widget-id',
'Widget Name', // shows on the backend
$opts
);
}
function form($instance) {
echo 'backend widget form (optional if you have not user configurable options)';
}
function update($new_instance,$old_instance) {
// Process backend form data
// optional if you don't have a 'form' method
}
function widget($args,$instance) {
echo 'Front end widget display';
}
}
function register_my_widgets() {
register_widget('WPSE_Widget_Shell');
}
add_action('widgets_init','register_my_widgets');
You are extend
ing the widget class at wp-includes/widgets.php
so it is good to keep an eye on the parent class. You can use the default widgets as patterns.