protected function setupSidebars($sidebars)
    {
        // load current widget condig
        $active_widgets = get_option('sidebars_widgets');

        // collect widgets to be added to sidebars
        foreach ($sidebars as $sidebar => $widgets) {
            $new_widgets = [];
            foreach ($widgets as $type => $data) {
                // load all widgets for this type
                $widget = get_option('widget_' . $type);

                // add a new widget and retrieve id
                $widget[] = $data;
                end($widget);
                $id = key($widget);

                // save the widgets back to db
                update_option('widget_' . $type, $widget);

                // add the new widget id to active widgets
                $new_widgets[] = $type . '-' . $id;
            }
            // set active widgets for sidebar
            $active_widgets[$sidebar] = $new_widgets;
        }
        // save sidebars with widgets
        update_option('sidebars_widgets', $active_widgets);
    }