WordPress.org

Make WordPress Core

Changeset 37322


Ignore:
Timestamp:
04/28/2016 06:19:15 PM (2 years ago)
Author:
westonruter
Message:

Customize: Remove format placeholders from widget templates and selectors, fixing a jQuery selector syntax error and the broken highlight/shift-click behaviors.

The issues occur in themes that register sidebars that reference a single format placeholder (%1$s and %2$s) multiple times, such as in the id and class attributes for $before_widget.

Props martin.krcho, westonruter.
Fixes #36473.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/customize-preview-widgets.js

    r37040 r37322  
    373373
    374374                widgetContainerElement = $(
    375                     sidebarPartial.params.sidebarArgs.before_widget.replace( '%1$s', widgetId ).replace( '%2$s', 'widget' ) +
     375                    sidebarPartial.params.sidebarArgs.before_widget.replace( /%1\$s/g, widgetId ).replace( /%2\$s/g, 'widget' ) +
    376376                    sidebarPartial.params.sidebarArgs.after_widget
    377377                );
     
    512512        $.each( self.registeredSidebars, function( i, sidebar ) {
    513513            var widgetTpl = [
    514                     sidebar.before_widget.replace( '%1$s', '' ).replace( '%2$s', '' ),
     514                    sidebar.before_widget,
    515515                    sidebar.before_title,
    516516                    sidebar.after_title,
     
    525525            widgetClasses = emptyWidget.prop( 'className' );
    526526
     527            // Remove class names that incorporate the string formatting placeholders %1$s and %2$s.
     528            widgetClasses = widgetClasses.replace( /\S*%[12]\$s\S*/g, '' );
     529            widgetClasses = widgetClasses.replace( /^\s+|\s+$/g, '' );
     530
    527531            // Prevent a rare case when before_widget, before_title, after_title and after_widget is empty.
    528532            if ( ! widgetClasses ) {
    529533                return;
    530534            }
    531 
    532             widgetClasses = widgetClasses.replace( /^\s+|\s+$/g, '' );
    533535
    534536            if ( widgetClasses ) {
Note: See TracChangeset for help on using the changeset viewer.