Ticket #22750: 22750.2.diff
| File 22750.2.diff, 1.6 KB (added by , 13 years ago) |
|---|
-
wp-includes/js/media-models.js
142 142 143 143 // Use with PHP's wp_send_json_success() and wp_send_json_error() 144 144 $.ajax( options ).done( function( response ) { 145 // Treat a response of `1` as successful for backwards 146 // compatibility with existing handlers. 147 if ( response === '1' || response === 1 ) 148 response = { success: true }; 149 145 150 if ( _.isObject( response ) && ! _.isUndefined( response.success ) ) 146 151 deferred[ response.success ? 'resolveWith' : 'rejectWith' ]( this, [response.data] ); 147 152 else … … 264 269 // This will permanently delete an attachment. 265 270 } else if ( 'delete' === method ) { 266 271 options = options || {}; 272 273 if ( ! options.wait ) 274 this.destroyed = true; 275 267 276 options.context = this; 268 277 options.data = _.extend( options.data || {}, { 269 278 action: 'delete-post', 270 279 id: this.id, 271 280 _wpnonce: this.get('nonces')['delete'] 272 281 }); 273 return media.ajax( options ); 282 283 return media.ajax( options ).done( function() { 284 this.destroyed = true; 285 }).fail( function() { 286 this.destroyed = false; 287 }); 274 288 } 275 289 }, 276 290 … … 401 415 this.reset( this._source.filter( this.validator, this ) ); 402 416 }, 403 417 418 validateDestroyed: false, 419 404 420 validator: function( attachment ) { 421 if ( ! this.validateDestroyed && attachment.destroyed ) 422 return false; 405 423 return _.all( this.filters, function( filter, key ) { 406 424 return !! filter.call( this, attachment ); 407 425 }, this );