Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#27299 new enhancement

Order the available widgets in the Widgets admin page

Reported by: nofearinc's profile nofearinc Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch needs-refresh
Focuses: administration Cc:

Description

The list of available widgets is always sorted alphabetically. Adding a hook would allow us to prioritize the order.

Sample patch attached.

Attachments (2)

27299.patch (418 bytes) - added by nofearinc 11 years ago.
propose a available_widgets_order filter
27299.2.patch (1.1 KB) - added by nofearinc 10 years ago.
Update docs and add to customizer too

Download all attachments as: .zip

Change History (9)

@nofearinc
11 years ago

propose a available_widgets_order filter

#1 @ocean90
10 years ago

  • Focuses accessibility removed

The new filter will need hook documentation.

The filter should probably exists here too: trunk/src/wp-includes/class-wp-customize-widgets.php@29903#L864

@nofearinc
10 years ago

Update docs and add to customizer too

#2 @nofearinc
10 years ago

Added the filter to the customizer and updated the inline docs.

#3 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 4.1

#4 @DrewAPicture
10 years ago

  • Keywords 2nd-opinion added

I have some concerns about the placement of the filter. If it's specific to ordering the widgets it should be tied specifically to a sorting function, such as maybe making the _sort_name_callback callback filterable.

I can easily see this getting misused for doing things like removing widgets from the list altogether or otherwise manipulating the list in ways that fall far outside the scope of simply changing the order.

If general filtering here is something we want to promote, great, rename the filter. If not, then maybe we should reconsider the implementation.

#5 @nofearinc
10 years ago

I would personally embrace complete filtering - restricting it doesn't make sense as a simple admin JS could hide it, similarly to what we did for live search filtering as mentioned in #27151. That said, _sort_name_callback would also be tricky if it's filtered since name ordering won't be the case anymore for some of the filters.

If the name is troubling, I can update the hook name to filter_available_widgets or something like that.

#6 @johnbillion
10 years ago

  • Milestone changed from 4.1 to Future Release

#7 @wonderboymusic
9 years ago

  • Keywords needs-refresh added; 2nd-opinion removed

I would make the filter occur before sorting actually happens to avoid sorting twice

Note: See TracTickets for help on using tickets.