This plugin is a simple demo test to see if I can dynamically populate a pre-existing widget area with text. In this case, my theme has created the widget area "home-header-widget" and I'm trying to populate it with the contents of 'text' below. I'm stuck at the line...
$sidebars_widgets[$sidebar_id] = "widget_text-".$id;
In that I'm not certain how to obtain a reference to the dynamically created text widget object in order to preset its contents and place it inside my 'home-header-widget'...
<?php
/*
Plugin Name: Widget Test
*/
function cb_activate_widgettest(){
$sidebar_id = 'home-header-widget';
$sidebars_widgets = get_option('sidebars_widgets');
$id = count($opts)+1;
$sidebars_widgets[$sidebar_id] = array("text-".$id);
$ops = get_option('widget_text');
// find an $id that works...
$ops[$id] = array(
'title' => 'foo hoo',
'text' => 'bar mitz', // content?
);
update_option('widget_text', $ops);
update_option('sidebars_widgets', $sidebars_widgets);
}
register_activation_hook(__FILE__, 'cb_activate_widgettest');
?>