[wp-trac] [WordPress Trac] #39907: Add "Remove all widgets" button for themes with multiple widget areas
WordPress Trac
noreply at wordpress.org
Sat Feb 18 21:05:20 UTC 2017
#39907: Add "Remove all widgets" button for themes with multiple widget areas
-------------------------+------------------------------
Reporter: karmatosed | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Comment (by westonruter):
@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:
{{{#!js
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 ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39907#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list