]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/customize-preview-widgets.js
WordPress 4.7-scripts
[autoinstalls/wordpress.git] / wp-includes / js / customize-preview-widgets.js
index 47972784f9101769a42f91368ac83a13ad585453..6c05e894317f289a45f26c9877a8574f0555d66b 100644 (file)
@@ -357,7 +357,6 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
                                widgetPartial = new self.WidgetPartial( partialId, {
                                        params: {}
                                } );
-                               api.selectiveRefresh.partial.add( widgetPartial.id, widgetPartial );
                        }
 
                        // Make sure that there is a container element for the widget in the sidebar, if at least a placeholder.
@@ -400,6 +399,8 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
                                wasInserted = true;
                        } );
 
+                       api.selectiveRefresh.partial.add( widgetPartial.id, widgetPartial );
+
                        if ( wasInserted ) {
                                sidebarPartial.reflowWidgets();
                        }
@@ -537,7 +538,9 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
                        // 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( '.' );
+                       if ( widgetClasses ) {
+                               widgetSelector += '.' + widgetClasses.split( /\s+/ ).join( '.' );
+                       }
                        self.widgetSelectors.push( widgetSelector );
                });
        };
@@ -570,6 +573,11 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
                var self = this,
                        selector = this.widgetSelectors.join( ',' );
 
+               // Skip adding highlights if not in the customizer preview iframe.
+               if ( ! api.settings.channel ) {
+                       return;
+               }
+
                $( selector ).attr( 'title', this.l10n.widgetTooltip );
 
                $( document ).on( 'mouseenter', selector, function() {