Home>Support>Automatically activate default widgets

Automatically activate default widgets

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

Hello SO Team.

Please is there a way to programmatically activate some default widgets?
I tried

SiteOrigin_Widgets_Bundle::single()->activate_widget('sow-features')
and even this

function mytheme_activate_wb_widget( $widgets ) {
  $widgets[] = 'sow-features';
  return $widgets;
}
add_filter('siteorigin_widgets_active_widgets', 'mytheme_activate_widget')

I put the code above in my functions.php and even tried it in a plugin.

Thanks.

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

  1. 7 years, 11 months ago Alex S
    Hi, I Work Here

    Hi Dave,

    I’d like to help you with this issue. Unfortunately, this is beyond the scope of the support we’re able to offer on our free forums. There is a fair amount of custom work involved.

    We do offer this level of support to our premium users, so if you’d like to upgrade to SiteOrigin Premium, then I can help you over email support.

    If you’d prefer not to upgrade to SiteOrigin Premium, then you can hire a WordPress developer from Codeable. They’ll charge you an hourly rate for any work done.

  2. 7 years, 10 months ago davexpression

    Thanks Alex.

    I am a WordPress Developer so I don’t need to hire a developer from Codeable. This worked for me

    $folder = WP_PLUGIN_DIR . '/so-widgets-bundle/widgets/';
    $widget_ids = array('testimonial'); //you can add more
    foreach ($widget_ids as $widget_id) {
    
    	if( !file_exists($folder . $widget_id . '/' . $widget_id . '.php') ) continue;
    		// There are times when we activate several widgets at once, so clear the cache.
    		wp_cache_delete( 'siteorigin_widgets_active', 'options' );
    		$active_widgets = SiteOrigin_Widgets_Bundle::single()->get_active_widgets();
    		$active_widgets[$widget_id] = true;
    		update_option( 'siteorigin_widgets_active', $active_widgets );
    		wp_cache_delete( 'active_widgets', 'siteorigin_widgets' );
    }
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