mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@38166 git-svn-id: http://core.svn.wordpress.org/trunk@38107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7e49f103be
commit
9ee1823d91
@ -376,6 +376,11 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
|
||||
sidebarPartial.params.sidebarArgs.after_widget
|
||||
);
|
||||
|
||||
// Handle rare case where before_widget and after_widget are empty.
|
||||
if ( ! widgetContainerElement[0] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
widgetContainerElement.attr( 'data-customize-partial-id', widgetPartial.id );
|
||||
widgetContainerElement.attr( 'data-customize-partial-type', 'widget' );
|
||||
widgetContainerElement.attr( 'data-customize-widget-id', widgetId );
|
||||
@ -521,21 +526,18 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
|
||||
widgetClasses;
|
||||
|
||||
emptyWidget = $( widgetTpl );
|
||||
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, '' );
|
||||
widgetSelector = emptyWidget.prop( 'tagName' ) || '';
|
||||
widgetClasses = emptyWidget.prop( 'className' ) || '';
|
||||
|
||||
// Prevent a rare case when before_widget, before_title, after_title and after_widget is empty.
|
||||
if ( ! widgetClasses ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( widgetClasses ) {
|
||||
widgetSelector += '.' + widgetClasses.split( /\s+/ ).join( '.' );
|
||||
}
|
||||
// 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, '' );
|
||||
widgetSelector += '.' + widgetClasses.split( /\s+/ ).join( '.' );
|
||||
self.widgetSelectors.push( widgetSelector );
|
||||
});
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.6-beta4-38165';
|
||||
$wp_version = '4.6-beta4-38166';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user