This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Automatically activate default widgets

8 years ago · Last reply by davexpression 8 years ago

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.

Need fast email support? Get SiteOrigin Premium

Replies

2
  1. Alex S Staff 8 years, 6 months ago

    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. davexpression 8 years, 5 months ago

    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.

Have a different question or issue?

Start New Thread