Widgets redesign

All of the redesigned widgets functionality is in place in trunk. Only remaining is some improvement to the visual design for the widgets screen in admin.

The new way to add widgets to WordPress is by extending WP_Widget. All widgets created that way have support for multiple instances.

Also all existing widgets will have to be converted to this system as the previous API functions will (most likely) be removed in 2.9. This is quite easy and any of the default widgets can be used as an example.

A typical widget is constructed as follows:

class WP_Widget_Archives extends WP_Widget {
	function WP_Widget_Archives() {
		$widget_ops = array('classname' => 'widget_archive', 'description' => __( "A monthly archive of your blog's posts") );
		$this->WP_Widget(false, __('Archives'), $widget_ops);
	}

	function widget( $args, $instance ) {
		// displays the widget on the front end
	}

	function update( $new_instance, $old_instance ) {
		// update the instance's settings
	}

	function form( $instance ) {
		// displays the widget admin form
	}
}

// register the widget
add_action('widgets_init', 'my_super_widget_init');
function my_super_widget_init() {
	register_widget('WP_Widget_Archives');
}

For more details and examples check wp-includes/widgets.php and wp-includes/default-widgets.php.

#widgets

Soliciting feedback on new Widgets API

Soliciting feedback on new Widgets API

#widgets

Converting default widgets to the new wi …

Converting default widgets to the new widgets API.

#widgets

Nice – widgets are running into some int …

Nice – widgets are running into some integer overflow bug.

#widgets

Going to clean up the new widget interfa …

Going to clean up the new widget interface so that cancel buttons really mean cancel.

[5886]

#widgets

Going to try to add descriptive info to …

Going to try to add descriptive info to titles for in-use-widgets in the admin early next week.

Text: {excerpt}…

#widgets

mdawaffe landed some dashboard widget ca …

mdawaffe landed some dashboard widget caching improvements.

#dashboard, #ui, #widgets

Mike landed the Plugins dashboard widget …

Mike landed the Plugins dashboard widget.

#dashboard, #plugins, #ui, #widgets