Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
43 views
in Plugins by
edited by

I am building a new widget and I would like to ask if there is any way programmatically to let admins to add this widget more than one times in the same position. In my case at the position "Main area -Top". How can I achieve this behavior?

I checked the file admin-widgets.php and found this part of code:

$region = $regioncodes[substr($place, 0, 1)];

    $widgetallowed = method_exists($module, 'allow_region') && $module->allow_region($region);

    if ($widgetallowed) {
        foreach ($widgets as $widget) {
            if ($widget['place'] == $place && $widget['title'] == $editwidget['title'] && $widget['widgetid'] !== @$editwidget['widgetid'])
                $widgetallowed = false; // don't allow two instances of same widget in same place
        }
    }


But how can I override this code in my custom widget file as I dont want to modify core files?? I need the $widgetallowed var to be true. -> $widgetallowed = true;

Q2A version: 1.8.8

Please log in or register to answer this question.

...