Twenty Eleven Child theme error when attempting to use a rewritten function

I attempted to make a minor change to a function in the Twenty Eleven theme (wordpress 3.4.2)

I get this error message:

Fatal error: Cannot redeclare twentyeleven_widgets_init() (previously declared in /home/labfocus/public_html/wp-content/themes/twentyeleven-child/functions.php:10) in /home/labfocus/public_html/wp-content/themes/twentyeleven/functions.php on line 438

Here is the function that I am attempting to add in place of the original

<?php
if ( !function_exists('twentyeleven_widgets_init')) {
/**
 * Register our sidebars and widgetized areas. Also register the default Ephemera widget.
 *
 * @since Twenty Eleven 1.0
 */
function twentyeleven_widgets_init() {

    register_widget( 'Twenty_Eleven_Ephemera_Widget' );

    register_sidebar( array(
        'name' => __( 'Main Sidebar', 'twentyeleven' ),
        'id' => 'sidebar-1',
        'before_widget' => '<div class="su-spoiler-title">%2$s</div><aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside></div>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

    register_sidebar( array(
        'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
        'id' => 'sidebar-2',
        'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

    register_sidebar( array(
        'name' => __( 'Footer Area One', 'twentyeleven' ),
        'id' => 'sidebar-3',
        'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

    register_sidebar( array(
        'name' => __( 'Footer Area Two', 'twentyeleven' ),
        'id' => 'sidebar-4',
        'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

    register_sidebar( array(
        'name' => __( 'Footer Area Three', 'twentyeleven' ),
        'id' => 'sidebar-5',
        'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    }
}

Can anyone see what’s wrong with this function?

Update: the question is really that I want to change how the Main Sidebar displays before_widget and after_widget. I’ve added a <div>

Solutions Collecting From Web of "Twenty Eleven Child theme error when attempting to use a rewritten function"

Why exactly are you trying to redeclare that function?

You can either edit the original function, or, better yet, use remove_action to remove add_action( 'widgets_init', 'twentyeleven_widgets_init' ); and then reattach your own function add_action('widgets_init', 'your_widgets_init_function' );

I had the same problem… SOLUTION: http://venutip.com/content/right-way-override-theme-functions
but use ‘after_setup_theme’ instead of ‘init’ or it won’t work because the child functions.php is called before the parent functions.php.
Another useful article: http://ottopress.com/2010/wordpress-protip-child-themes/