Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#39907 new enhancement

Add "Remove all widgets" button for themes with multiple widget areas

Reported by: karmatosed's profile karmatosed Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Customize Keywords: 2nd-opinion
Focuses: Cc:


I was loading giving one of my sites a new theme as a New Year treat. It only seemed fitting to put on Twenty Sixteen. As this was a simple site, I wanted the single column. Unfortunately, loading up the theme brought a few issues as I suddenly found a lot of widgets I didn't want. For example the footer areas, they were filled with defaults I didn't want. Going in and removing each one took several steps as there were multiples.

Whether you want defaults or not may be something the theme can decide, but offering a 'remove all widgets' button I think would be easy enough to add into the Customizer and a great enhancement for the minimalists.

Change History (5)

#1 @westonruter
7 years ago

@karmatosed so you're thinking of something that appears next to the current Reorder link and Add Widget button?

Aside, here is a JS snippet for clearing out a widget area:

function emptyWidgetArea( sidebarId ) {
        var targetSidebarSetting, inactiveSidebarSetting, widgetIds;
        targetSidebarSetting = wp.customize('sidebars_widgets[' + sidebarId + ']');
        inactiveSidebarSetting = wp.customize('sidebars_widgets[wp_inactive_widgets]');

        // Grab existing widget IDs from sidebar.
        widgetIds = targetSidebarSetting.get();

        // Clear out sidebar of widgets.
        targetSidebarSetting.set( [] );

        // Append removed widget IDs to the inactive sidebar.
        inactiveSidebarSetting.set( inactiveSidebarSetting.get().concat( widgetIds ) );

#2 @karmatosed
7 years ago

@westonruter let me do some sketches and show what I'm thinking. It'll help visualise.

#3 @westonruter
7 years ago

#40844 was marked as a duplicate.

#4 @krizpers
6 years ago

@westonruter @karmatosed Where are we with this fix? I would like to help develop this if we are still interested in the issue. I run into a similar problem a lot and I think it could save a lot of time in future projects, even though it isn't something that I encounter all the time. Maybe we could add a check box for bulk actions, we could give users the option to temporarily disable/activate widgets as well as delete them. If this is an issue we are interested in fixing then I could work on a small fix to start off with and we could build from there.

#5 @celloexpressions
3 years ago

  • Keywords 2nd-opinion added

Would this still be useful with widgets being replaced with blocks in 5.8? Within a widget area, you can now bulk-select and delete or even backspace to delete, instead of the previous workflow to open each widget separately to delete. #21666 has further discussion on the idea of broader resetting.

This could be considered (partially) fixed in 5.8 or potentially closed as wontfix or maybelater - does anyone else have thoughts?

Note: See TracTickets for help on using tickets.