WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#37478 closed defect (bug) (fixed)

Customizer undefined property if widget area before/after values are empty

Reported by: Clorith Owned by: westonruter
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.6
Component: Customize Keywords: has-patch needs-testing
Focuses: javascript Cc:
PR Number:

Description

Introduced in r37322 the replace on widgetClasses casts a TypeError if all the before_widget, after_widget, before_title and after_title fields are declared as an empty string in a theme when registering a widget area through register_sidebar

A quick example registration;

<?php
register_sidebar( array(
        'name'          => __( 'Sidebar' ),
        'id'            => 'sidebar-1',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => '',
) );

As reported by @stevengliebe in https://wordpress.org/support/topic/customizer-js-error-when-register_sidebar-beforeafter-arguments-empty

Attachments (1)

37478.0.diff (1.9 KB) - added by westonruter 3 years ago.

Download all attachments as: .zip

Change History (6)

@westonruter
3 years ago

#1 @westonruter
3 years ago

  • Keywords has-patch needs-testing added
  • Milestone changed from Awaiting Review to 4.6
  • Owner set to westonruter
  • Status changed from new to accepted

@stevengliebe Please give 37478.0.diff a try.

#2 @stevengliebe
3 years ago

That solves it for me. Thanks for working on this.

This ticket was mentioned in Slack in #core-customize by ocean90. View the logs.


3 years ago

#4 @westonruter
3 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 38166:

Customize: Prevent customize-preview-widgets JS errors in preview if a sidebar is registered with empty before_widget/after_widget params.

Selective refresh will not be available for widgets when they lack these params, so previewing will fallback to full page refreshes. Sidebars registered as such should be rare so this accounts for an edge case.

Fixes #37478.

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


3 years ago

Note: See TracTickets for help on using tickets.