Attached is a patch for the new widgets interface.
Features
- Can filter widgets by simple search and/or whether or not you're currently using them.
- Widgets can now be given descriptions (all core widgets have descriptions in this patch).
- Addition/Removal via mouse clicks rather than drag and drop.
- Sorting via drag and drop.
- More or less friendly to those without JS: you can still add, remove, and update widgets without JS. You cannot currently change their order without JS.
Issues
- Each widget has a save button, but it doesn't actually save the data. You need to click the "global" "Save Changes" button. The individual save buttons should maybe be relabeled "OK" buttons.
- Cannot drag a widget from one sidebar to another.
- The CSS for this page was kept separate from wp-admin.css do reduce conflicts during "The great redesign of fiscal year 2008". It's in wp-admin/includes/widgets.php:temp_widget_css() and should be unified and merged with wp-admin.css at some point.
- The CSS is rough cut. It will need some polish.
Widgets can be written so that an arbitrary number of instances of that widget may appear in your sidebars. There is no longer a need for the hacky "How many text widgets do you want" UI.
Replacing that hack is another: widgets that want to allow multiple instances should accept a 'number' argument, provide an 'id_base' (so that unique widget ids can be constructed from {id_base}-{number}, and have a widget_control form that can be used as a template for generating control forms for each instance (and for new instances during JS on-the-fly).
Included in this patch are several examples (the text widget, the categories widget, the rss widget) of such "many instance widgets". Also included are some docs that:
- Detail what a "many instance widget" control form should look like.
- Offer a pattern for creating your own "many instance widgets".
These docs are located in a comment block at the end of wp-includes/widgets.php.
Things to note:
- Widget id#s are no longer persistent across multiple updates. In order to prevent duplication or poisoning within or between different sidebars, widgets that allow mulitple instances will have widget ids that look like {id_base}-{timestamp . incrementor}.
- The JS is not yet internationalized.
Everything should work cleanly, but please back any important widget data before testing this just in case.