File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,22 +184,17 @@ Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototyp
184184 batchSize = batchSize || 50 ;
185185
186186 var promises = [ ] ,
187- i , slice , ids , nonces ;
187+ i , slice , data ;
188188
189189 for ( i = 0 ; i < models . length ; i += batchSize ) {
190- slice = models . slice ( i , i + batchSize ) ;
191- ids = [ ] ;
192- nonces = { } ;
193-
194- _ . each ( slice , function ( model ) {
195- ids . push ( model . id ) ;
196- nonces [ model . id ] = model . get ( 'nonces' ) [ 'delete' ] ;
197- } ) ;
198-
199- promises . push ( wp . media . post ( 'delete-post-batch' , {
200- ids : ids ,
201- nonces : nonces
202- } ) ) ;
190+ slice = models . slice ( i , i + batchSize ) ;
191+ data = _ . reduce ( slice , function ( acc , model ) {
192+ acc . ids . push ( model . id ) ;
193+ acc . nonces [ model . id ] = model . get ( 'nonces' ) [ 'delete' ] ;
194+ return acc ;
195+ } , { ids : [ ] , nonces : { } } ) ;
196+
197+ promises . push ( wp . media . post ( 'delete-post-batch' , data ) ) ;
203198 }
204199
205200 return $ . when . apply ( null , promises ) . then ( function ( ) {
You can’t perform that action at this time.
0 commit comments