Here is some code I used to build a very simple widget.
1) Put this at the bottom of the widgets.php file in the business-directory-pluig folder.
class WPBDP_CategoriesWidget extends WP_Widget {
public function __construct() {
parent::__construct(false,
_x('Business Directory - Categories', 'widgets', 'WPBDM'),
array('description' => _x('Displays a list of the latest categories in the Business Directory.', 'widgets', 'WPBDM')));
}
public function form($instance) {
if (isset($instance['title']))
$title = $instance['title'];
else
$title = _x('Directory Categories', 'widgets', 'WPBDM');
}
public function update($new_instance, $old_instance) {
$new_instance['title'] = strip_tags($new_instance['title']);
return $new_instance;
}
public function widget($args, $instance) {
$title = ( $instance['title'] ) ? $instance['title'] : 'Directory Categories';
extract($args);
//$title = apply_filters( 'widget_title', $instance['title'] );
echo $before_widget;
if ( ! empty( $title ) )
echo $before_title . $title . $after_title;
echo wpbdp_the_directory_categories();
echo $after_widget;
}
}
2) Add registration of widget into wpbusdirman.php around line 788
register_widget(‘WPBDP_CategoriesWidget’);
All done, should appear in widgets section. Please note I am very new to programming wordpress and there could be problems, so use at your own discretion.