Home>Support>Autoactivate widget after plugin activation (Livemesh SiteOrigin Widgets)

Autoactivate widget after plugin activation (Livemesh SiteOrigin Widgets)

By ChristiaanG, 3 months ago. Last reply by Alex S, 3 months ago.

Hi,

We are using Livemesh SiteOrigin Widgets in our theme and would like to activate the testimonal slider widget after the plugin is installed and activated by default. I use the code underneath but for some reason the whole WordPress installation gets broken after the plugin is activated. Also, I first have to click next in the box that appears for live connection. When I put back the code after this the activation works.

Any idea how to pass this or how to see if this boxed is passed and then let the code does his thing?

/**
 * Activate Siteorigin Livemesh widget after import
 */

if ( is_plugin_active( 'livemesh-siteorigin-widgets/livemesh-siteorigin-widgets.php' ) ) {

$folder = WP_PLUGIN_DIR . '/livemesh-siteorigin-widgets/includes/widgets/';
$widget_ids = array('lsow-testimonials-slider-widget');
foreach ($widget_ids as $widget_id) {

	if( !file_exists($folder . $widget_id . '/' . $widget_id . '.php') ) continue;

		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' );
}

} 

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. 3 months, 6 days ago Alex S Hi, I Work Here

    Hi Chris,

    The provided code is working without issue for me. Can you please provide me with a copy of the error message you receive after adding the PHP? If you don’t see an error message and instead see a blank page, please enable WP_DEBUG. This will allow for the error message to appear instead of a blank page.

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