WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 19 months ago

#39907 new enhancement

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

Reported by: karmatosed Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:
PR Number:

Description

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 (4)

#1 @westonruter
3 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
3 years ago

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

#3 @westonruter
2 years ago

#40844 was marked as a duplicate.

#4 @krizpers
19 months 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.

Note: See TracTickets for help on using tickets.