I'm attempting to dynamically create a text widget, add it to a named sidebar widget that my theme has already created ($sidebar_id = 'home-header-widget'), then populate the text widget with some preset content. I'm getting an error as indicated above at line 35 (commented below). Any ideas what I'm doing wrong?
Parse error: syntax error, unexpected '[' in C:....widgettest.php on line 35
<?php
/*
Plugin Name: Widget Test
*/
function cb_activate_widgettest(){
$ops = get_option('widget_text');
// find an $id that works...
$ops[$id] = array(
'title' => '',
'text' => 'bar', // content?
);
update_option('widget_text', $ops);
$sidebar_id = 'home-header-widget';
$sidebars_widgets = get_option('sidebars_widgets');
$sidebars_widgets[$sidebar_id] = ["widget_text-$id"]; //this is line 35
update_option('sidebars_widgets', $sidebars_widgets);
}
register_activation_hook(__FILE__, 'cb_activate_widgettest');
?>