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.

Built from https://develop.svn.wordpress.org/trunk@37322


git-svn-id: http://core.svn.wordpress.org/trunk@37288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-04-28 18:20:29 +00:00
parent 7726afe693
commit 09860ae46c
3 changed files with 8 additions and 6 deletions

View File

@ -372,7 +372,7 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
}
widgetContainerElement = $(
sidebarPartial.params.sidebarArgs.before_widget.replace( '%1$s', widgetId ).replace( '%2$s', 'widget' ) +
sidebarPartial.params.sidebarArgs.before_widget.replace( /%1\$s/g, widgetId ).replace( /%2\$s/g, 'widget' ) +
sidebarPartial.params.sidebarArgs.after_widget
);
@ -511,7 +511,7 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
$.each( self.registeredSidebars, function( i, sidebar ) {
var widgetTpl = [
sidebar.before_widget.replace( '%1$s', '' ).replace( '%2$s', '' ),
sidebar.before_widget,
sidebar.before_title,
sidebar.after_title,
sidebar.after_widget
@ -524,13 +524,15 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
widgetSelector = emptyWidget.prop( 'tagName' );
widgetClasses = emptyWidget.prop( 'className' );
// Remove class names that incorporate the string formatting placeholders %1$s and %2$s.
widgetClasses = widgetClasses.replace( /\S*%[12]\$s\S*/g, '' );
widgetClasses = widgetClasses.replace( /^\s+|\s+$/g, '' );
// Prevent a rare case when before_widget, before_title, after_title and after_widget is empty.
if ( ! widgetClasses ) {
return;
}
widgetClasses = widgetClasses.replace( /^\s+|\s+$/g, '' );
if ( widgetClasses ) {
widgetSelector += '.' + widgetClasses.split( /\s+/ ).join( '.' );
}

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-alpha-37321';
$wp_version = '4.6-alpha-37322';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.