Home>Support>Enable new widget by default

Enable new widget by default

Hi There,

First of congratulations for creating great plugin. I’m loving it.

I am a theme developer and includes your page builder in my themes. I used to build widgets WordPress way and include it as a separate plugin which client can activate while activating the theme. Now as you have come up with “Widgets Bundle” plugin, it’s lot easier to create widgets for pagebuilder. Now I’m converting all widgets using “Widget Bundle” as a framework and providing all widgets inside the theme only so they don’t have to activate them as a plugin.

Just one issue doing so, I don’t want clients to go to plugins > “Site Origin Widgets” to activate widgets, I want my theme widgets to be active when client activates the theme and other required plugins including “Site Origin Page Builder”.

I badly need a way to activate the widgets automatically rather going to page and activating a widget. Can you please show me how can I achieve that?

Thanks for great work.

Thanks,
Vrushank

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 9 years, 4 months ago Greg Priday
    Hi, I Work Here

    Hi Vrushank

    Awesome to hear you’re building on top of the WB framework! Always makes me happy to hear that it’s making developer’s lives a little easier. There are 2 options you have here. The first is to use the widget activation function. You can use this from anywhere. It’s best suited to a function that runs after your theme/plugin activation.

    SiteOrigin_Widgets_Bundle::single()->activate_widget('my-widget-id');

    The main problem there is that themes don’t have an activation function like plugins do.

    Another option is to filter the siteorigin_widgets_active_widgets value. This will force the widget to always be active, regardless of whether the user tries to deactivate it in Plugins > SiteOrigin Widgets.

    function mytheme_activate_wb_widget( $widgets ) {  $widgets['my-widget-id] = true;  return $widgets;}add_filter('siteorigin_widgets_active_widgets', 'mytheme_activate_widget')

    Hopefully that points you in the right direction :)

  2. 9 years, 3 months ago vrushank

    Greg, You are simply awesome.

    Does the job for me.

    Thanks a lot for helping me out!!

  3. 9 years, 3 months ago Greg Priday
    Hi, I Work Here

    It’s a pleasure :) Always happy to help out.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More