diff --git src/wp-admin/js/customize-widgets.js src/wp-admin/js/customize-widgets.js
index 0f42db3..48ba335 100644
|
|
|
|
| 36 | 36 | transport: 'refresh', |
| 37 | 37 | params: [], |
| 38 | 38 | width: null, |
| 39 | | height: null |
| | 39 | height: null, |
| | 40 | search_matched: true |
| 40 | 41 | }); |
| 41 | 42 | |
| 42 | 43 | /** |
| … |
… |
|
| 71 | 72 | // If search is blank, show all themes |
| 72 | 73 | // Useful for resetting the views when you clean the input |
| 73 | 74 | if ( this.terms === '' ) { |
| 74 | | this.reset( api.Widgets.data.availableWidgets ); |
| | 75 | this.each( function ( widget ) { |
| | 76 | widget.set( 'search_matched', true ); |
| | 77 | } ); |
| 75 | 78 | } |
| 76 | | |
| 77 | | // Trigger an 'update' event |
| 78 | | this.trigger( 'update' ); |
| 79 | 79 | }, |
| 80 | 80 | |
| 81 | 81 | // Performs a search within the collection |
| 82 | 82 | // @uses RegExp |
| 83 | 83 | search: function( term ) { |
| 84 | | var match, results, haystack; |
| 85 | | |
| 86 | | // Start with a full collection |
| 87 | | this.reset( api.Widgets.data.availableWidgets, { silent: true } ); |
| | 84 | var match, haystack; |
| 88 | 85 | |
| 89 | 86 | // Escape the term string for RegExp meta characters |
| 90 | 87 | term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' ); |
| … |
… |
|
| 94 | 91 | term = term.replace( / /g, ')(?=.*' ); |
| 95 | 92 | match = new RegExp( '^(?=.*' + term + ').+', 'i' ); |
| 96 | 93 | |
| 97 | | results = this.filter( function( data ) { |
| 98 | | haystack = _.union( data.get( 'name' ), data.get( 'id' ), data.get( 'description' ) ); |
| 99 | | |
| 100 | | return match.test( haystack ); |
| 101 | | }); |
| 102 | | |
| 103 | | this.reset( results ); |
| | 94 | this.each( function ( data ) { |
| | 95 | haystack = [ data.get( 'name' ), data.get( 'id' ), data.get( 'description' ) ].join( ' ' ); |
| | 96 | data.set( 'search_matched', match.test( haystack ) ); |
| | 97 | } ); |
| 104 | 98 | } |
| 105 | 99 | }); |
| 106 | 100 | api.Widgets.availableWidgets = new api.Widgets.WidgetCollection( api.Widgets.data.availableWidgets ); |
| … |
… |
|
| 176 | 170 | |
| 177 | 171 | _.bindAll( this, 'close' ); |
| 178 | 172 | |
| 179 | | this.listenTo( this.collection, 'update', this.updateList ); |
| 180 | 173 | this.listenTo( this.collection, 'change', this.updateList ); |
| 181 | 174 | |
| 182 | 175 | this.updateList(); |
| … |
… |
|
| 222 | 215 | } |
| 223 | 216 | }, |
| 224 | 217 | |
| 225 | | // Changes visibilty of available widgets |
| | 218 | // Changes visibility of available widgets |
| 226 | 219 | updateList: function() { |
| 227 | | // First hide all widgets... |
| 228 | | this.$el.find( '.widget-tpl' ).hide(); |
| 229 | | |
| 230 | | // ..and then show only available widgets which could be filtered |
| 231 | 220 | this.collection.each( function( widget ) { |
| 232 | 221 | var widgetTpl = $( '#widget-tpl-' + widget.id ); |
| 233 | | widgetTpl.toggle( ! widget.get( 'is_disabled' ) ); |
| | 222 | widgetTpl.toggle( widget.get( 'search_matched' ) && ! widget.get( 'is_disabled' ) ); |
| 234 | 223 | if ( widget.get( 'is_disabled' ) && widgetTpl.is( this.selected ) ) { |
| 235 | 224 | this.selected = null; |
| 236 | 225 | } |
| 237 | 226 | } ); |
| 238 | 227 | }, |
| 239 | 228 | |
| 240 | | // Hightlights a widget |
| | 229 | // Highlights a widget |
| 241 | 230 | select: function( widgetTpl ) { |
| 242 | 231 | this.selected = $( widgetTpl ); |
| 243 | 232 | this.selected.siblings( '.widget-tpl' ).removeClass( 'selected' ); |
| 244 | 233 | this.selected.addClass( 'selected' ); |
| 245 | 234 | }, |
| 246 | 235 | |
| 247 | | // Hightlights a widget on focus |
| | 236 | // Highlights a widget on focus |
| 248 | 237 | focus: function( event ) { |
| 249 | 238 | this.select( $( event.currentTarget ) ); |
| 250 | 239 | }, |
| … |
… |
|
| 1601 | 1590 | |
| 1602 | 1591 | /** |
| 1603 | 1592 | * @param {string} widgetId or an id_base for adding a previously non-existing widget |
| 1604 | | * @returns {object} widget_form control instance |
| | 1593 | * @returns {object|false} widget_form control instance, or false on error |
| 1605 | 1594 | */ |
| 1606 | 1595 | addWidget: function( widgetId ) { |
| 1607 | 1596 | var self = this, controlHtml, $widget, controlType = 'widget_form', $control, controlConstructor, |
| … |
… |
|
| 1612 | 1601 | settingId, isExistingWidget, widgetFormControl, sidebarWidgets, settingArgs; |
| 1613 | 1602 | |
| 1614 | 1603 | if ( ! widget ) { |
| 1615 | | return; |
| | 1604 | return false; |
| 1616 | 1605 | } |
| 1617 | 1606 | |
| 1618 | 1607 | if ( widgetNumber && ! widget.get( 'is_multi' ) ) { |
| 1619 | | return; |
| | 1608 | return false; |
| 1620 | 1609 | } |
| 1621 | 1610 | |
| 1622 | 1611 | // Set up new multi widget |
diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
index adeb3f0..72ff397 100644
|
|
|
final class WP_Customize_Widgets {
|
| 1150 | 1150 | $added_input_vars = array(); |
| 1151 | 1151 | if ( ! empty( $_POST['sanitized_widget_setting'] ) ) { |
| 1152 | 1152 | $sanitized_widget_setting = json_decode( $this->get_post_value( 'sanitized_widget_setting' ), true ); |
| 1153 | | if ( empty( $sanitized_widget_setting ) ) { |
| | 1153 | if ( false === $sanitized_widget_setting ) { |
| 1154 | 1154 | $this->stop_capturing_option_updates(); |
| 1155 | 1155 | return new WP_Error( 'widget_setting_malformed' ); |
| 1156 | 1156 | } |