Support » Alpha/Beta/RC » Customizer JS error when register_sidebar() before/after arguments empty

  • Resolved Steven Gliebe

    (@stevengliebe)



    I’m seeing “Cannot read property ‘replace’ of undefined” in console when a theme registers a sidebar using empty values for before_widget, after_widget, before_title and after_title. This does not happen with 4.5 or earlier.

    Here are steps to recreate the issue using the default theme.

    1. Edit functions.php in Twenty Sixteen 1.2 to cause the problem. This is how it is before the change.

    register_sidebar( array(
    	'name'          => __( 'Sidebar', 'twentysixteen' ),
    	'id'            => 'sidebar-1',
    	'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentysixteen' ),
    	'before_widget' => '<section id="%1$s" class="widget %2$s">',
    	'after_widget'  => '</section>',
    	'before_title'  => '<h2 class="widget-title">',
    	'after_title'   => '</h2>',
    ) );

    Empty before_widget, after_widget, before_title and after_title like this.

    register_sidebar( array(
    	'name'          => __( 'Sidebar', 'twentysixteen' ),
    	'id'            => 'sidebar-1',
    	'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentysixteen' ),
    	'before_widget' => '',
    	'after_widget'  => '',
    	'before_title'  => '',
    	'after_title'   => '',
    ) );

    2. Activate Twenty Sixteen

    3. Go to Customizer > Widgets > Sidebar

    4. Add Pages widget (chose this at random)

    5. See console for error (while in Customizer)

    Edit: Removed notes on this working when arguments are omitted instead of empty. Not a good workaround since then default tags are used. There are cases in which it is necessary to use empty values.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customizer JS error when register_sidebar() before/after arguments empty’ is closed to new replies.