| 1 | Index: wp-includes/js/media-models.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/media-models.js (revision 23056) |
|---|
| 4 | +++ wp-includes/js/media-models.js (working copy) |
|---|
| 5 | @@ -263,6 +263,7 @@ |
|---|
| 6 | // Overload the `delete` request so attachments can be removed. |
|---|
| 7 | // This will permanently delete an attachment. |
|---|
| 8 | } else if ( 'delete' === method ) { |
|---|
| 9 | + this.destroyed = true; |
|---|
| 10 | options = options || {}; |
|---|
| 11 | options.context = this; |
|---|
| 12 | options.data = _.extend( options.data || {}, { |
|---|
| 13 | @@ -270,7 +271,10 @@ |
|---|
| 14 | id: this.id, |
|---|
| 15 | _wpnonce: this.get('nonces')['delete'] |
|---|
| 16 | }); |
|---|
| 17 | - return media.ajax( options ); |
|---|
| 18 | + |
|---|
| 19 | + return media.ajax( options ).fail( function() { |
|---|
| 20 | + this.destroyed = false; |
|---|
| 21 | + }); |
|---|
| 22 | } |
|---|
| 23 | }, |
|---|
| 24 | |
|---|
| 25 | @@ -401,7 +405,11 @@ |
|---|
| 26 | this.reset( this._source.filter( this.validator, this ) ); |
|---|
| 27 | }, |
|---|
| 28 | |
|---|
| 29 | + validateDestroyed: false, |
|---|
| 30 | + |
|---|
| 31 | validator: function( attachment ) { |
|---|
| 32 | + if ( ! this.validateDestroyed && attachment.destroyed ) |
|---|
| 33 | + return false; |
|---|
| 34 | return _.all( this.filters, function( filter, key ) { |
|---|
| 35 | return !! filter.call( this, attachment ); |
|---|
| 36 | }, this ); |
|---|