There's no easy way. If you really need to limit it, run this query to find out the total number of instances installed, and fire an error.
$x = $DB->get_var('SELECT COUNT(*) wi_ID FROM T_widgets WHERE wi_code = "my-widget-code"');
if( $x > 5 )
{
$this->msg('Stop adding this widget!', 'error');
}
The problem is that there's no plugin event to hook up to in b2evo v4. It's only available in b2evo 5 :( So you may have to run this code in SessionLoaded and only on widget add request in backoffice.
There's no easy way. If you really need to limit it, run this query to find out the total number of instances installed, and fire an error.
The problem is that there's no plugin event to hook up to in b2evo v4. It's only available in b2evo 5 :( So you may have to run this code in SessionLoaded and only on widget add request in backoffice.