Opened 17 years ago
Closed 17 years ago
#5583 closed enhancement (fixed)
New widgets interface
Reported by: | mdawaffe | Owned by: | mdawaffe |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
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.
Attachments (9)
Change History (39)
#3
follow-up:
↓ 6
@
17 years ago
GULP -- No worky, array errors all over the place. (Lines 650 and 1171 in particular)
#4
@
17 years ago
Warning: Invalid argument supplied for foreach() on 650, Warning: array_keys() [function.array-keys]: The first argument should be an array on 1171.
#6
in reply to:
↑ 3
@
17 years ago
Replying to zamoose:
GULP -- No worky, array errors all over the place. (Lines 650 and 1171 in particular)
Try 5583b.diff above.
#9
@
17 years ago
interface.js is no longer maintained and has some incompatibilities with jQuery 1.2, which we're now using. Can we move to jQuery UI?
#11
@
17 years ago
I've looked at jQuery UI, but have not had any success with it so far.
Its 1.0 release is not compatible with noConflict. Its trunk is broken. I haven't seen any working jQuery UI Sortable demos.
#12
follow-up:
↓ 13
@
17 years ago
@mdawaffe:
I guess the question then needs to be asked: is it worth continuing to operate in noConflict mode, given the fact that we're (ostensibly) removing all need for Prototype in the admin interface?
Is there any utility in forcing jQuery to work around a namespace that isn't in use?
#13
in reply to:
↑ 12
;
follow-ups:
↓ 14
↓ 16
@
17 years ago
Replying to zamoose:
Is there any utility in forcing jQuery to work around a namespace that isn't in use?
Maybe not in core, but what about all those plugins out there that still depend on Prototype?
#14
in reply to:
↑ 13
@
17 years ago
Replying to Nazgul:
Maybe not in core, but what about all those plugins out there that still depend on Prototype?
Hmmmm. Good point. Here I was, thinking that we were only concerned with the admin, but if the bundled jQuery we include stomps on $(), then I could indeed see that causing issues. Shazbot.
Has anyone filed a "make it work with noConflict" bug with the UI folk? *grin*
#16
in reply to:
↑ 13
@
17 years ago
Replying to Nazgul:
Replying to zamoose:
Is there any utility in forcing jQuery to work around a namespace that isn't in use?
Maybe not in core, but what about all those plugins out there that still depend on Prototype?
It would be possible to only set noConflict() mode if Prototype was loaded too perhaps?, But even then, That would mean we couldnt rely on $ being jQuery...
Unfortunately i think most plugins which load Prototype load it for the entire admin interface rather than just for their plugin page, I had that problem quite often when using jQuery's $() in my plugin interface. In the end i specifically deregistered the Prototype script on my plugins admin page and that fixed that.
#17
@
17 years ago
We definitely need to keep noConflict around for plugins.
The jQuery people themselves recommend using jQuery rather than $ most places: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
Their recommendation on how to do that easily is a great one:
(function($) { // plugin code here, use $ as much as you like })(jQuery);
That method also automatically makes it harder to contaminate the global JS namespace.
#19
@
17 years ago
I've attached some patches to fix the bug in IE7 in which Interface sortables don't work.
interface-fix.js is the actual fix, compressed
interface-fix2.diff reverts the hack in wp-admin/js/widgets.js, and it changes script-loader so that whenever someone queues Interface, the fix is queued afterwards.
interface-repacked.diff is just the fix applied to Interface directly, then Interface is repacked. This is an alternate solution to queuing the fix script.
#22
@
17 years ago
I forgot about the interface fixes. I'm fine with the fix and repack of interface.
#23
@
17 years ago
I have forgotten the changes in script-loader.php
in the i18n patch. They are in the new patch.
#27
@
17 years ago
- Owner changed from anonymous to mdawaffe
- Status changed from new to assigned
5583d.diff
- Move css to own file (replacing old widgets.css).
- CSS and markup tweaks
- Some changes to wp-admin.css for new design.
- RTL it up.
big