title: How to auto activate WordPress widgets? (New Widgets_API WP_Widget class)
body: <p>I gave up on this finally.</p>
  
  <p>I am developing something on WordPress 2.8.4. I am impressed by the ease of new widgets API which allows you to use extends WP_Widget and create widgets that have multiple instances easily. But I am facing a problem.</p>
  
  <p>How can I auto-activate the widget on theme activation? I've tried to use:</p>
  
  <pre><code>add_action('sidebars_widgets', array('sidebar-1', array('uc_tagcloud')));
  </code></pre>
  
  <p>But with no success. the problem is that New wordpress API creates widget ids and adds a unique id to the end of ID automatically. So I just can't get the hang of it. I've tried the above solution but the actual widget ID by viewing source code always displays uc_tagcloud-2 or 3 or 4..etc etc.. a new instance every time i add the widget.</p>
  
  <p>I would appreciate any thought, I've deeply thought about it and searched the internet for hours now. So this is my last chance.</p>
  
  <p>I basically do not want users to drag and enable them manually.</p>
  
  <p>Below is a sample widget I've developed. It works fine if i drag and put it in relevant sidebar. But I do not know how .. my question is : how can I activate it automatically into specific sidebar without draggin it manually (WP_Widget new Widgets API)</p>
  
  <p>This is code of widget:</p>
  
  <pre><code>&lt;?php
  /**********************************************************************
  Widget: Tag Cloud List
  **********************************************************************/
  class uc_tagcloud extends WP_Widget {
  
   // Constructor
   function uc_tagcloud() {
    $widget_ops = array('description' =&gt; __('A list of your blog tags for your sidebar','ucms'));
    $this-&gt;WP_Widget('uc_tagcloud', __('ultimaCMS - Tag Cloud','ucms'), $widget_ops);
   }
  
   // Display Widget
   function widget($args, $instance) {
    extract($args);
    $title = esc_attr($instance['title']);
    $num = intval($instance['num']);
    echo $before_widget.$before_title.$title.$after_title;
  
    // Display widget content
    ?&gt;
    &lt;?php wp_tag_cloud('smallest=9&amp;largest=22&amp;number='.$num); ?&gt;
    &lt;?php
  
    echo $after_widget;
   }
  
   // When Widget Control Form Is Posted
   function update($new_instance, $old_instance) {
    if (!isset($new_instance['submit'])) {
     return false;
    }
    $instance = $old_instance;
    $instance['title'] = strip_tags($new_instance['title']);
    $instance['num'] = intval($new_instance['num']);
    return $instance;
   }
  
   // DIsplay Widget Control Form
   function form($instance) {
    global $wpdb;
    $instance = wp_parse_args((array) $instance, array('title' =&gt; __('Tag Cloud','ucms'), 'num' =&gt; 100));
    $title = esc_attr($instance['title']);
    $num = intval($instance['num']);
  ?&gt;
  
  &lt;p&gt;
  &lt;label for="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"&gt;&lt;?php _e('Title:','ucms'); ?&gt;&lt;/label&gt;
  &lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('title'); ?&gt;" type="text" value="&lt;?php echo $title; ?&gt;" /&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
  &lt;label for="&lt;?php echo $this-&gt;get_field_id('num'); ?&gt;"&gt;&lt;?php _e('Number of tags:','ucms'); ?&gt;&lt;/label&gt;
  &lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('num'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('num'); ?&gt;" type="text" value="&lt;?php echo $num; ?&gt;" /&gt;
  &lt;br /&gt;&lt;small&gt;Enter 0 to display all tags&lt;/small&gt;
  &lt;/p&gt;
  
  &lt;input type="hidden" id="&lt;?php echo $this-&gt;get_field_id('submit'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('submit'); ?&gt;" value="1" /&gt;
  
  &lt;?php
   }
  }
  
  ### Initiate widget
  add_action('widgets_init', 'uc_tagcloud_init');
  function uc_tagcloud_init() {
   register_widget('uc_tagcloud');
  }
  ?&gt;
  </code></pre>
  
  <p>It's very simple, the new API i love it. But I just can't get how to auto activate an instance of the widget on specific sidebar. Any help?</p>