I want to cleanup all inactive widgets. I tried following snippet as suggested by this answer Script to remove all inactive widgets?.
$sidebars_widgets = get_option( 'sidebars_widgets' );
$sidebars_widgets['wp_inactive_widgets'] = array();
update_option( 'sidebars_widgets', $sidebars_widgets );
I also tried deleting option sidebars_widgets
directly from the options table.
But after page is refreshed, old value is restored with all inactive widgets. How can I remove all those inactive widgets at once? Thanks in advance.