Make WordPress Core

Changeset 30409 for branches/4.0


Ignore:
Timestamp:
11/20/2014 11:08:11 AM (12 years ago)
Author:
nacin
Message:

Media Grid: Don't attempt to delete an attachment that can't be deleted.

Merges [29755] to the 4.0 branch.

props wonderboymusic.
fixes #29597.

Location:
branches/4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/src/wp-includes/js/media-views.js

    r29686 r30409  
    58515851                                        priority: -60,
    58525852                                        click: function() {
    5853                                                 var model, changed = [], self = this,
     5853                                                var changed = [], removed = [], self = this,
    58545854                                                        selection = this.controller.state().get( 'selection' ),
    58555855                                                        library = this.controller.state().get( 'library' );
     
    58705870                                                }
    58715871
    5872                                                 while ( selection.length > 0 ) {
    5873                                                         model = selection.at( 0 );
     5872                                                selection.each( function( model ) {
     5873                                                        if ( ! model.get( 'nonces' )['delete'] ) {
     5874                                                                removed.push( model );
     5875                                                                return;
     5876                                                        }
     5877
    58745878                                                        if ( media.view.settings.mediaTrash && 'trash' === model.get( 'status' ) ) {
    58755879                                                                model.set( 'status', 'inherit' );
    58765880                                                                changed.push( model.save() );
    5877                                                                 selection.remove( model );
     5881                                                                removed.push( model );
    58785882                                                        } else if ( media.view.settings.mediaTrash ) {
    58795883                                                                model.set( 'status', 'trash' );
    58805884                                                                changed.push( model.save() );
    5881                                                                 selection.remove( model );
     5885                                                                removed.push( model );
    58825886                                                        } else {
    58835887                                                                model.destroy();
    58845888                                                        }
    5885                                                 }
     5889                                                } );
    58865890
    58875891                                                if ( changed.length ) {
     5892                                                        selection.remove( removed );
     5893
    58885894                                                        $.when.apply( null, changed ).then( function() {
    58895895                                                                library._requery( true );
Note: See TracChangeset for help on using the changeset viewer.